Fix cron service

This commit is contained in:
Vins 2023-07-25 11:14:18 +02:00
parent 69585af4db
commit ed0a41acaf
2 changed files with 30 additions and 5 deletions

View File

@ -87,9 +87,7 @@ export class BackendVariables {
this.MAILCHIMP_API_KEY = process.env["MAILCHIMP_API_KEY"]!;
this.ENV = process.env["ENV"]!;
}
public async validate(groups?: string[]) {
console.log(this);
public async validate(groups?: string[]) {
const validationOptions = groups ? { groups } : undefined;
try {

View File

@ -1,16 +1,43 @@
import "module-alias/register";
import "reflect-metadata";
import { Container } from "typedi";
import CronService from "@Services/common/CronService/CronService";
import ExpressServer from "@Common/system/ExpressServer";
import routes from "@App/index";
import cors from "cors";
import bodyParser from "body-parser";
import errorHandler from "@App/middlewares/ErrorHandler";
import { BackendVariables } from "@Common/config/variables/Variables";
import multer from "multer";
import CronService from "@Services/common/CronService/CronService";
const storage = multer.memoryStorage();
(async () => {
try {
const variables = await Container.get(BackendVariables).validate();
if(variables.ENV === "stg"){
Container.get(CronService).sendMails();
}
const port = variables.APP_PORT;
const rootUrl = variables.APP_ROOT_URL;
const label = variables.APP_LABEL ?? "Unknown Service";
Container.get(ExpressServer).init({
label,
port: parseInt(port),
rootUrl,
middlwares: [
cors({ origin: "*" }),
multer({ storage: storage }).single("file"),
bodyParser.urlencoded({ extended: true }),
bodyParser.json(),
],
errorHandler,
});
routes.start();
} catch (e) {
console.error(e);
}
})();
})();