2024-08-22 09:40:31 +00:00
|
|
|
import "dotenv/config";
|
|
|
|
import express from "express";
|
|
|
|
|
2024-08-25 16:07:34 +00:00
|
|
|
import { configCheck, SERVER_PORT } from "./env.defaults";
|
|
|
|
configCheck();
|
|
|
|
|
2024-08-22 09:40:31 +00:00
|
|
|
declare global {
|
|
|
|
namespace Express {
|
|
|
|
export interface Request {
|
|
|
|
userId: string;
|
|
|
|
username: string;
|
2024-08-27 09:47:27 +00:00
|
|
|
permissions: PermissionObject;
|
2024-08-22 09:40:31 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
import { dataSource } from "./data-source";
|
|
|
|
|
|
|
|
dataSource.initialize();
|
|
|
|
|
|
|
|
const app = express();
|
|
|
|
import router from "./routes/index";
|
2024-08-26 11:47:08 +00:00
|
|
|
import { PermissionObject } from "./type/permissionTypes";
|
2024-08-22 09:40:31 +00:00
|
|
|
router(app);
|
2024-08-25 16:07:34 +00:00
|
|
|
app.listen(SERVER_PORT, () => {
|
|
|
|
console.log(`listening on *:${SERVER_PORT}`);
|
2024-08-22 09:40:31 +00:00
|
|
|
});
|
2024-09-04 12:01:22 +00:00
|
|
|
|
|
|
|
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();
|
|
|
|
});
|