240 lines
7.1 KiB
TypeScript
240 lines
7.1 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 DATABASE_URL!: string;
|
|
|
|
@IsNotEmpty()
|
|
public readonly API_ROOT_URL!: string;
|
|
|
|
@IsNotEmpty()
|
|
public readonly APP_HOST!: string;
|
|
|
|
@IsOptional()
|
|
public readonly APP_LABEL!: string;
|
|
|
|
@IsNotEmpty()
|
|
public readonly APP_PORT!: string;
|
|
|
|
@IsNotEmpty()
|
|
public readonly APP_ROOT_URL!: string;
|
|
|
|
@IsNotEmpty()
|
|
public readonly IDNOT_BASE_URL!: string;
|
|
|
|
@IsNotEmpty()
|
|
public readonly IDNOT_API_BASE_URL!: string;
|
|
|
|
@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;
|
|
|
|
@IsNotEmpty()
|
|
public readonly IDNOT_API_KEY!: string;
|
|
|
|
@IsNotEmpty()
|
|
public readonly PINATA_API_KEY!: string;
|
|
|
|
@IsNotEmpty()
|
|
public readonly PINATA_API_SECRET!: string;
|
|
|
|
@IsNotEmpty()
|
|
public readonly PINATA_GATEWAY!: string;
|
|
|
|
@IsNotEmpty()
|
|
public readonly PINATA_GATEWAY_TOKEN!: string;
|
|
|
|
@IsNotEmpty()
|
|
public readonly ACCESS_TOKEN_SECRET!: string;
|
|
|
|
@IsNotEmpty()
|
|
public readonly REFRESH_TOKEN_SECRET!: string;
|
|
|
|
@IsNotEmpty()
|
|
public readonly MAILCHIMP_API_KEY!: string;
|
|
|
|
@IsNotEmpty()
|
|
public readonly SECURE_API_KEY!: string;
|
|
|
|
@IsNotEmpty()
|
|
public readonly SECURE_API_BASE_URL!: string;
|
|
|
|
@IsNotEmpty()
|
|
public readonly ENV!: string;
|
|
|
|
@IsNotEmpty()
|
|
public readonly DOCAPOST_BASE_URL!: string;
|
|
|
|
@IsNotEmpty()
|
|
public readonly DOCAPOST_ROOT!: string;
|
|
|
|
@IsNotEmpty()
|
|
public readonly DOCAPOST_VERSION!: string;
|
|
|
|
@IsNotEmpty()
|
|
public readonly DOCAPOST_DOCUMENT_PROCESS_ID!: string;
|
|
|
|
@IsNotEmpty()
|
|
public readonly DOCAPOST_CONNECT_PROCESS_ID!: string;
|
|
|
|
@IsNotEmpty()
|
|
public readonly BACK_API_HOST!: string;
|
|
|
|
@IsNotEmpty()
|
|
public readonly DOCAPOST_APP_ID!: string;
|
|
|
|
@IsNotEmpty()
|
|
public readonly DOCAPOST_APP_PASSWORD!: string;
|
|
|
|
@IsNotEmpty()
|
|
public readonly SMS_PROVIDER!: string;
|
|
|
|
@IsNotEmpty()
|
|
public readonly OVH_APP_KEY!: string;
|
|
|
|
@IsNotEmpty()
|
|
public readonly OVH_APP_SECRET!: string;
|
|
|
|
@IsNotEmpty()
|
|
public readonly OVH_CONSUMER_KEY!: string;
|
|
|
|
@IsNotEmpty()
|
|
public readonly OVH_SMS_SERVICE_NAME!: string;
|
|
|
|
@IsNotEmpty()
|
|
public readonly SMS_FACTOR_TOKEN!: string;
|
|
|
|
@IsNotEmpty()
|
|
public readonly SCW_ACCESS_KEY_ID!: string;
|
|
|
|
@IsNotEmpty()
|
|
public readonly SCW_ACCESS_KEY_SECRET!: string;
|
|
|
|
@IsNotEmpty()
|
|
public readonly SCW_BUCKET_ENDPOINT!: string;
|
|
|
|
@IsNotEmpty()
|
|
public readonly SCW_BUCKET_NAME!: string;
|
|
|
|
@IsNotEmpty()
|
|
public readonly STRIPE_SECRET_KEY!: string;
|
|
|
|
@IsNotEmpty()
|
|
public readonly STRIPE_STANDARD_SUBSCRIPTION_PRICE_ID!: string;
|
|
|
|
@IsNotEmpty()
|
|
public readonly STRIPE_STANDARD_ANNUAL_SUBSCRIPTION_PRICE_ID!: string;
|
|
|
|
@IsNotEmpty()
|
|
public readonly STRIPE_UNLIMITED_SUBSCRIPTION_PRICE_ID!: string;
|
|
|
|
@IsNotEmpty()
|
|
public readonly STRIPE_UNLIMITED_ANNUAL_SUBSCRIPTION_PRICE_ID!: string;
|
|
|
|
@IsNotEmpty()
|
|
public readonly IDNOT_PROD_BASE_URL!: string;
|
|
|
|
@IsNotEmpty()
|
|
public readonly MAILCHIMP_KEY!: string;
|
|
|
|
@IsNotEmpty()
|
|
public readonly MAILCHIMP_LIST_ID!: 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.DATABASE_URL = process.env["DEV_PRISMA_STUDIO_DB_URL"]!;
|
|
this.API_ROOT_URL = process.env["API_ROOT_URL"]!;
|
|
this.APP_HOST = process.env["APP_HOST"]!;
|
|
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_BASE_URL = process.env["IDNOT_BASE_URL"]!;
|
|
this.IDNOT_API_BASE_URL = process.env["IDNOT_API_BASE_URL"]!;
|
|
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"]!;
|
|
this.IDNOT_API_KEY = process.env["IDNOT_API_KEY"]!;
|
|
this.PINATA_API_KEY = process.env["PINATA_API_KEY"]!;
|
|
this.PINATA_API_SECRET = process.env["PINATA_API_SECRET"]!;
|
|
this.PINATA_GATEWAY = process.env["PINATA_GATEWAY"]!;
|
|
this.PINATA_GATEWAY_TOKEN = process.env["PINATA_GATEWAY_TOKEN"]!;
|
|
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.SECURE_API_KEY = process.env["SECURE_API_KEY"]!;
|
|
this.SECURE_API_BASE_URL = process.env["SECURE_API_BASE_URL"]!;
|
|
this.ENV = process.env["ENV"]!;
|
|
this.DOCAPOST_BASE_URL = process.env["DOCAPOST_BASE_URL"]!;
|
|
this.DOCAPOST_ROOT = process.env["DOCAPOST_ROOT"]!;
|
|
this.DOCAPOST_VERSION = process.env["DOCAPOST_VERSION"]!;
|
|
this.DOCAPOST_DOCUMENT_PROCESS_ID = process.env["DOCAPOST_DOCUMENT_PROCESS_ID"]!;
|
|
this.DOCAPOST_CONNECT_PROCESS_ID = process.env["DOCAPOST_CONNECT_PROCESS_ID"]!;
|
|
this.BACK_API_HOST = process.env["BACK_API_HOST"]!;
|
|
this.DOCAPOST_APP_ID = process.env["DOCAPOST_APP_ID"]!;
|
|
this.DOCAPOST_APP_PASSWORD = process.env["DOCAPOST_APP_PASSWORD"]!;
|
|
this.SMS_PROVIDER = process.env["SMS_PROVIDER"]!;
|
|
this.OVH_APP_KEY = process.env["OVH_APP_KEY"]!;
|
|
this.OVH_APP_SECRET = process.env["OVH_APP_SECRET"]!;
|
|
this.OVH_CONSUMER_KEY = process.env["OVH_CONSUMER_KEY"]!;
|
|
this.OVH_SMS_SERVICE_NAME = process.env["OVH_SMS_SERVICE_NAME"]!;
|
|
this.SMS_FACTOR_TOKEN = process.env["SMS_FACTOR_TOKEN"]!;
|
|
this.SCW_ACCESS_KEY_ID = process.env["ACCESS_KEY_ID"]!;
|
|
this.SCW_ACCESS_KEY_SECRET = process.env["ACCESS_KEY_SECRET"]!;
|
|
this.SCW_BUCKET_ENDPOINT = process.env["BUCKET_ENDPOINT"]!;
|
|
this.SCW_BUCKET_NAME = process.env["BUCKET_NAME"]!;
|
|
this.STRIPE_SECRET_KEY = process.env["STRIPE_SECRET_KEY"]!;
|
|
this.STRIPE_STANDARD_SUBSCRIPTION_PRICE_ID = process.env["STRIPE_STANDARD_SUBSCRIPTION_PRICE_ID"]!;
|
|
this.STRIPE_STANDARD_ANNUAL_SUBSCRIPTION_PRICE_ID = process.env["STRIPE_STANDARD_ANNUAL_SUBSCRIPTION_PRICE_ID"]!;
|
|
this.STRIPE_UNLIMITED_SUBSCRIPTION_PRICE_ID = process.env["STRIPE_UNLIMITED_SUBSCRIPTION_PRICE_ID"]!;
|
|
this.STRIPE_UNLIMITED_ANNUAL_SUBSCRIPTION_PRICE_ID = process.env["STRIPE_UNLIMITED_ANNUAL_SUBSCRIPTION_PRICE_ID"]!;
|
|
this.IDNOT_PROD_BASE_URL = process.env["IDNOT_PROD_BASE_URL"]!;
|
|
this.MAILCHIMP_KEY = process.env["MAILCHIMP_KEY"]!;
|
|
this.MAILCHIMP_LIST_ID = process.env["MAILCHIMP_LIST_ID"]!;
|
|
}
|
|
public async validate(groups?: string[]) {
|
|
const validationOptions = groups ? { groups } : undefined;
|
|
|
|
try {
|
|
await validateOrReject(this, validationOptions);
|
|
} catch (error: any) {
|
|
if (process.env["ENV"] === "dev" || process.env["ENV"] === "stg") {
|
|
throw error;
|
|
}
|
|
throw new Error("Some env variables are required!");
|
|
}
|
|
return this;
|
|
}
|
|
}
|