Added env variable
This commit is contained in:
parent
bd2518bb38
commit
18497903a3
@ -63,6 +63,9 @@ export class BackendVariables {
|
||||
@IsNotEmpty()
|
||||
public readonly MAILCHIMP_API_KEY!: string;
|
||||
|
||||
@IsNotEmpty()
|
||||
public readonly ENV!: string;
|
||||
|
||||
public constructor() {
|
||||
dotenv.config();
|
||||
this.DATABASE_PORT = process.env["DATABASE_PORT"]!;
|
||||
@ -84,6 +87,7 @@ export class BackendVariables {
|
||||
this.ACCESS_TOKEN_SECRET = process.env["ACCESS_TOKEN_SECRET"]!;
|
||||
this.REFRESH_TOKEN_SECRET = process.env["REFRESH_TOKEN_SECRET"]!;
|
||||
this.MAILCHIMP_API_KEY = process.env["MAILCHIMP_API_KEY"]!;
|
||||
this.ENV = process.env["ENV"]!;
|
||||
}
|
||||
public async validate(groups?: string[]) {
|
||||
const validationOptions = groups ? { groups } : undefined;
|
||||
|
@ -2,10 +2,12 @@ import "module-alias/register";
|
||||
import "reflect-metadata";
|
||||
import { Container } from "typedi";
|
||||
import CronService from "@Services/common/CronService/CronService";
|
||||
import { BackendVariables } from "@Common/config/variables/Variables";
|
||||
|
||||
(async () => {
|
||||
try {
|
||||
if(process.env["MAILCHIMP_API_KEY"] === "stg"){
|
||||
const variables = await Container.get(BackendVariables).validate();
|
||||
if(variables.ENV === "stg"){
|
||||
Container.get(CronService).sendMails();
|
||||
}
|
||||
} catch (e) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user