69 lines
1.8 KiB
TypeScript
69 lines
1.8 KiB
TypeScript
import { IsNotEmpty, IsOptional, validateOrReject } from "class-validator";
|
|
import dotenv from "dotenv";
|
|
import { Service } from "typedi";
|
|
|
|
@Service()
|
|
export class BackendVariables {
|
|
@IsNotEmpty()
|
|
public readonly DATABASE_PORT!: string;
|
|
|
|
@IsNotEmpty()
|
|
public readonly DATABASE_HOST!: string;
|
|
|
|
@IsNotEmpty()
|
|
public readonly DATABASE_USERNAME!: string;
|
|
|
|
@IsNotEmpty()
|
|
public readonly DATABASE_PASSWORD!: string;
|
|
|
|
@IsNotEmpty()
|
|
public readonly DATABASE_NAME!: string;
|
|
|
|
@IsNotEmpty()
|
|
public readonly API_ROOT_URL!: string;
|
|
|
|
@IsOptional()
|
|
public readonly APP_LABEL!: string;
|
|
|
|
@IsNotEmpty()
|
|
public readonly APP_PORT!: string;
|
|
|
|
@IsNotEmpty()
|
|
public readonly APP_ROOT_URL!: string;
|
|
|
|
public readonly NODE_ENV = process.env.NODE_ENV;
|
|
|
|
@IsNotEmpty()
|
|
public readonly IDNOT_CONNEXION_URL!: string;
|
|
|
|
@IsNotEmpty()
|
|
public readonly IDNOT_CLIENT_ID!: string;
|
|
|
|
@IsNotEmpty()
|
|
public readonly IDNOT_CLIENT_SECRET!: string;
|
|
|
|
@IsNotEmpty()
|
|
public readonly IDNOT_REDIRECT_URL!: string;
|
|
|
|
public constructor() {
|
|
dotenv.config();
|
|
this.DATABASE_PORT = process.env["DATABASE_PORT"]!;
|
|
this.DATABASE_HOST = process.env["DATABASE_HOST"]!;
|
|
this.DATABASE_USERNAME = process.env["DATABASE_USERNAME"]!;
|
|
this.DATABASE_PASSWORD = process.env["DATABASE_PASSWORD"]!;
|
|
this.DATABASE_NAME = process.env["DATABASE_NAME"]!;
|
|
this.API_ROOT_URL = process.env["API_ROOT_URL"]!;
|
|
this.APP_PORT = process.env["APP_PORT"]!;
|
|
this.APP_ROOT_URL = process.env["APP_ROOT_URL"]!;
|
|
this.APP_LABEL = process.env["APP_LABEL"]!;
|
|
this.IDNOT_CONNEXION_URL = process.env["IDNOT_CONNEXION_URL"]!;
|
|
this.IDNOT_CLIENT_ID = process.env["IDNOT_CLIENT_ID"]!;
|
|
this.IDNOT_CLIENT_SECRET = process.env["IDNOT_CLIENT_SECRET"]!;
|
|
this.IDNOT_REDIRECT_URL = process.env["IDNOT_REDIRECT_URL"]!;
|
|
}
|
|
public async validate() {
|
|
await validateOrReject(this);
|
|
return this;
|
|
}
|
|
}
|