Fix cron service
This commit is contained in:
parent
69585af4db
commit
ed0a41acaf
@ -88,8 +88,6 @@ export class BackendVariables {
|
|||||||
this.ENV = process.env["ENV"]!;
|
this.ENV = process.env["ENV"]!;
|
||||||
}
|
}
|
||||||
public async validate(groups?: string[]) {
|
public async validate(groups?: string[]) {
|
||||||
console.log(this);
|
|
||||||
|
|
||||||
const validationOptions = groups ? { groups } : undefined;
|
const validationOptions = groups ? { groups } : undefined;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
@ -1,15 +1,42 @@
|
|||||||
import "module-alias/register";
|
import "module-alias/register";
|
||||||
import "reflect-metadata";
|
import "reflect-metadata";
|
||||||
import { Container } from "typedi";
|
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 { BackendVariables } from "@Common/config/variables/Variables";
|
||||||
|
import multer from "multer";
|
||||||
|
import CronService from "@Services/common/CronService/CronService";
|
||||||
|
|
||||||
|
const storage = multer.memoryStorage();
|
||||||
|
|
||||||
(async () => {
|
(async () => {
|
||||||
try {
|
try {
|
||||||
const variables = await Container.get(BackendVariables).validate();
|
const variables = await Container.get(BackendVariables).validate();
|
||||||
|
|
||||||
if(variables.ENV === "stg"){
|
if(variables.ENV === "stg"){
|
||||||
Container.get(CronService).sendMails();
|
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) {
|
} catch (e) {
|
||||||
console.error(e);
|
console.error(e);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user