refactor(server/middleware): inject ficmas data into request context via middleware

to make sure people can't see ficmas stories in listings
This commit is contained in:
parent 997962e391
commit 421a283d6c
Signed by: tablet
GPG Key ID: 924A5F6AF051E87C

@ -0,0 +1,22 @@
import { Ficmas } from "~/models/challenges/ficmas";
export default eventHandler(async (event) => {
let y = new Date().getFullYear()
let fmfilt: any = {};
if (!!process.env.JulyFicmas && new Date() < new Date(Date.parse('Aug 1 ' + y))) {
fmfilt.isAnniversary = true;
fmfilt.year = y;
} else if (new Date() < new Date(Date.parse('Dec 25 ' + y))) {
fmfilt.year = process.env.YEAR;
fmfilt.isAnniversary = false;
} else {
fmfilt.keythatdoesntexist = {
$exists: true
}
}
let ficmasarray_raw = await Ficmas.find(fmfilt)
// console.log(ficsHidden());
// console.log(query);
event.context.ficmasarray_raw = ficmasarray_raw
})