ff-admin-server/src/index.ts
2024-12-18 12:55:03 +01:00

34 lines
904 B
TypeScript

import "dotenv/config";
import express from "express";
import { configCheck, SERVER_PORT } from "./env.defaults";
configCheck();
import { PermissionObject } from "./type/permissionTypes";
declare global {
namespace Express {
export interface Request {
userId: string;
username: string;
isOwner: boolean;
permissions: PermissionObject;
}
}
}
import { dataSource } from "./data-source";
dataSource.initialize();
const app = express();
import router from "./routes/index";
router(app);
app.listen(process.env.NODE_ENV ? SERVER_PORT : 5000, () => {
console.log(`listening on *:${SERVER_PORT}`);
});
import schedule from "node-schedule";
import RefreshCommandHandler from "./command/refreshCommandHandler";
const job = schedule.scheduleJob("0 0 * * *", async () => {
console.log(`running Cron at ${new Date()}`);
await RefreshCommandHandler.deleteExpired();
});