next/server/middleware/10.ficmasData.ts

21 lines
580 B
TypeScript
Raw Normal View History

import { Ficmas } from "@models/challenges/ficmas";
2023-10-03 01:19:36 -04:00
export default eventHandler(async (event) => {
let y = new Date().getFullYear();
let fmfilt: any = {};
2023-12-29 20:53:29 -05:00
if (!!process.env.JulyFicmas && new Date() < new Date(Date.parse("Aug 1 " + y))) {
2023-10-03 01:19:36 -04:00
fmfilt.isAnniversary = true;
fmfilt.year = y;
} else if (new Date() < new Date(Date.parse("Dec 25 " + y))) {
fmfilt.year = y;
2023-10-03 01:19:36 -04:00
fmfilt.isAnniversary = false;
} else {
fmfilt.keythatdoesntexist = {
$exists: true,
};
}
let ficmasarray_raw = await Ficmas.find(fmfilt);
event.context.ficmasarray_raw = ficmasarray_raw;
});