@ -1,17 +1,11 @@
|
|||||||
import { ConfigService } from '@nestjs/config';
|
|
||||||
|
|
||||||
import console from 'console';
|
import console from 'console';
|
||||||
|
|
||||||
import { DataSource } from 'typeorm';
|
import { DataSource } from 'typeorm';
|
||||||
|
|
||||||
import { EnvironmentService } from 'src/engine/integrations/environment/environment.service';
|
|
||||||
|
|
||||||
const environmentService = new EnvironmentService(new ConfigService());
|
|
||||||
|
|
||||||
export const connectionSource = new DataSource({
|
export const connectionSource = new DataSource({
|
||||||
type: 'postgres',
|
type: 'postgres',
|
||||||
logging: false,
|
logging: false,
|
||||||
url: environmentService.get('PG_DATABASE_URL'),
|
url: process.env.PG_DATABASE_URL,
|
||||||
});
|
});
|
||||||
|
|
||||||
export const camelToSnakeCase = (str) =>
|
export const camelToSnakeCase = (str) =>
|
||||||
|
|||||||
@ -1,11 +1,8 @@
|
|||||||
import { ConfigService } from '@nestjs/config';
|
|
||||||
|
|
||||||
import { CommandFactory } from 'nest-commander';
|
import { CommandFactory } from 'nest-commander';
|
||||||
|
|
||||||
import { filterException } from 'src/engine/utils/global-exception-handler.util';
|
import { filterException } from 'src/engine/utils/global-exception-handler.util';
|
||||||
import { ExceptionHandlerService } from 'src/engine/integrations/exception-handler/exception-handler.service';
|
import { ExceptionHandlerService } from 'src/engine/integrations/exception-handler/exception-handler.service';
|
||||||
import { LoggerService } from 'src/engine/integrations/logger/logger.service';
|
import { LoggerService } from 'src/engine/integrations/logger/logger.service';
|
||||||
import { EnvironmentService } from 'src/engine/integrations/environment/environment.service';
|
|
||||||
|
|
||||||
import { CommandModule } from './command.module';
|
import { CommandModule } from './command.module';
|
||||||
|
|
||||||
@ -20,10 +17,8 @@ async function bootstrap() {
|
|||||||
exceptionHandlerService.captureExceptions([err]);
|
exceptionHandlerService.captureExceptions([err]);
|
||||||
};
|
};
|
||||||
|
|
||||||
const environmentService = new EnvironmentService(new ConfigService());
|
|
||||||
|
|
||||||
const app = await CommandFactory.createWithoutRunning(CommandModule, {
|
const app = await CommandFactory.createWithoutRunning(CommandModule, {
|
||||||
bufferLogs: environmentService.get('LOGGER_IS_BUFFER_ENABLED'),
|
bufferLogs: process.env.LOGGER_IS_BUFFER_ENABLED === 'true',
|
||||||
errorHandler,
|
errorHandler,
|
||||||
serviceErrorHandler: errorHandler,
|
serviceErrorHandler: errorHandler,
|
||||||
});
|
});
|
||||||
|
|||||||
@ -1,13 +1,11 @@
|
|||||||
import { ConfigService } from '@nestjs/config';
|
|
||||||
import { TypeOrmModuleOptions } from '@nestjs/typeorm';
|
import { TypeOrmModuleOptions } from '@nestjs/typeorm';
|
||||||
|
|
||||||
import { DataSource, DataSourceOptions } from 'typeorm';
|
import { DataSource, DataSourceOptions } from 'typeorm';
|
||||||
import { config } from 'dotenv';
|
import { config } from 'dotenv';
|
||||||
config();
|
config();
|
||||||
const configService = new ConfigService();
|
|
||||||
|
|
||||||
export const typeORMCoreModuleOptions: TypeOrmModuleOptions = {
|
export const typeORMCoreModuleOptions: TypeOrmModuleOptions = {
|
||||||
url: configService.get('PG_DATABASE_URL'),
|
url: process.env.PG_DATABASE_URL,
|
||||||
type: 'postgres',
|
type: 'postgres',
|
||||||
logging: ['error'],
|
logging: ['error'],
|
||||||
schema: 'core',
|
schema: 'core',
|
||||||
|
|||||||
@ -1,13 +1,11 @@
|
|||||||
import { ConfigService } from '@nestjs/config';
|
|
||||||
import { TypeOrmModuleOptions } from '@nestjs/typeorm';
|
import { TypeOrmModuleOptions } from '@nestjs/typeorm';
|
||||||
|
|
||||||
import { DataSource, DataSourceOptions } from 'typeorm';
|
import { DataSource, DataSourceOptions } from 'typeorm';
|
||||||
import { config } from 'dotenv';
|
import { config } from 'dotenv';
|
||||||
config();
|
config();
|
||||||
const configService = new ConfigService();
|
|
||||||
|
|
||||||
export const typeORMMetadataModuleOptions: TypeOrmModuleOptions = {
|
export const typeORMMetadataModuleOptions: TypeOrmModuleOptions = {
|
||||||
url: configService.get('PG_DATABASE_URL'),
|
url: process.env.PG_DATABASE_URL,
|
||||||
type: 'postgres',
|
type: 'postgres',
|
||||||
logging: ['error'],
|
logging: ['error'],
|
||||||
schema: 'metadata',
|
schema: 'metadata',
|
||||||
|
|||||||
@ -262,12 +262,14 @@ export class EnvironmentVariables {
|
|||||||
|
|
||||||
REDIS_HOST: string = '127.0.0.1';
|
REDIS_HOST: string = '127.0.0.1';
|
||||||
|
|
||||||
|
@CastToPositiveNumber()
|
||||||
REDIS_PORT: number = 6379;
|
REDIS_PORT: number = 6379;
|
||||||
|
|
||||||
API_TOKEN_EXPIRES_IN: string = '100y';
|
API_TOKEN_EXPIRES_IN: string = '100y';
|
||||||
|
|
||||||
SHORT_TERM_TOKEN_EXPIRES_IN: string = '5m';
|
SHORT_TERM_TOKEN_EXPIRES_IN: string = '5m';
|
||||||
|
|
||||||
|
@CastToBoolean()
|
||||||
MESSAGING_PROVIDER_GMAIL_ENABLED: boolean = false;
|
MESSAGING_PROVIDER_GMAIL_ENABLED: boolean = false;
|
||||||
|
|
||||||
MESSAGING_PROVIDER_GMAIL_CALLBACK_URL: string;
|
MESSAGING_PROVIDER_GMAIL_CALLBACK_URL: string;
|
||||||
@ -284,6 +286,7 @@ export class EnvironmentVariables {
|
|||||||
|
|
||||||
EMAIL_SMTP_HOST: string;
|
EMAIL_SMTP_HOST: string;
|
||||||
|
|
||||||
|
@CastToPositiveNumber()
|
||||||
EMAIL_SMTP_PORT: number = 587;
|
EMAIL_SMTP_PORT: number = 587;
|
||||||
|
|
||||||
EMAIL_SMTP_USER: string;
|
EMAIL_SMTP_USER: string;
|
||||||
@ -292,14 +295,18 @@ export class EnvironmentVariables {
|
|||||||
|
|
||||||
OPENROUTER_API_KEY: string;
|
OPENROUTER_API_KEY: string;
|
||||||
|
|
||||||
|
@CastToPositiveNumber()
|
||||||
API_RATE_LIMITING_TTL: number = 100;
|
API_RATE_LIMITING_TTL: number = 100;
|
||||||
|
|
||||||
|
@CastToPositiveNumber()
|
||||||
API_RATE_LIMITING_LIMIT: number = 500;
|
API_RATE_LIMITING_LIMIT: number = 500;
|
||||||
|
|
||||||
CACHE_STORAGE_TYPE: string = 'memory';
|
CACHE_STORAGE_TYPE: string = 'memory';
|
||||||
|
|
||||||
|
@CastToPositiveNumber()
|
||||||
CACHE_STORAGE_TTL: number = 3600 * 24 * 7;
|
CACHE_STORAGE_TTL: number = 3600 * 24 * 7;
|
||||||
|
|
||||||
|
@CastToBoolean()
|
||||||
CALENDAR_PROVIDER_GOOGLE_ENABLED: boolean = false;
|
CALENDAR_PROVIDER_GOOGLE_ENABLED: boolean = false;
|
||||||
|
|
||||||
AUTH_GOOGLE_APIS_CALLBACK_URL: string;
|
AUTH_GOOGLE_APIS_CALLBACK_URL: string;
|
||||||
@ -307,7 +314,9 @@ export class EnvironmentVariables {
|
|||||||
CHROME_EXTENSION_REDIRECT_URL: string;
|
CHROME_EXTENSION_REDIRECT_URL: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
export const validate = (config: Record<string, unknown>) => {
|
export const validate = (
|
||||||
|
config: Record<string, unknown>,
|
||||||
|
): EnvironmentVariables => {
|
||||||
const validatedConfig = plainToClass(EnvironmentVariables, config);
|
const validatedConfig = plainToClass(EnvironmentVariables, config);
|
||||||
|
|
||||||
const errors = validateSync(validatedConfig);
|
const errors = validateSync(validatedConfig);
|
||||||
|
|||||||
@ -1,7 +1,6 @@
|
|||||||
import { NestFactory } from '@nestjs/core';
|
import { NestFactory } from '@nestjs/core';
|
||||||
import { ValidationPipe } from '@nestjs/common';
|
import { ValidationPipe } from '@nestjs/common';
|
||||||
import { NestExpressApplication } from '@nestjs/platform-express';
|
import { NestExpressApplication } from '@nestjs/platform-express';
|
||||||
import { ConfigService } from '@nestjs/config';
|
|
||||||
|
|
||||||
import * as Sentry from '@sentry/node';
|
import * as Sentry from '@sentry/node';
|
||||||
import { graphqlUploadExpress } from 'graphql-upload';
|
import { graphqlUploadExpress } from 'graphql-upload';
|
||||||
@ -14,15 +13,13 @@ import { AppModule } from './app.module';
|
|||||||
import { generateFrontConfig } from './utils/generate-front-config';
|
import { generateFrontConfig } from './utils/generate-front-config';
|
||||||
import { settings } from './engine/constants/settings';
|
import { settings } from './engine/constants/settings';
|
||||||
import { LoggerService } from './engine/integrations/logger/logger.service';
|
import { LoggerService } from './engine/integrations/logger/logger.service';
|
||||||
import { EnvironmentService } from './engine/integrations/environment/environment.service';
|
|
||||||
|
|
||||||
const bootstrap = async () => {
|
const bootstrap = async () => {
|
||||||
const environmentService = new EnvironmentService(new ConfigService());
|
|
||||||
const app = await NestFactory.create<NestExpressApplication>(AppModule, {
|
const app = await NestFactory.create<NestExpressApplication>(AppModule, {
|
||||||
cors: true,
|
cors: true,
|
||||||
bufferLogs: environmentService.get('LOGGER_IS_BUFFER_ENABLED'),
|
bufferLogs: process.env.LOGGER_IS_BUFFER_ENABLED === 'true',
|
||||||
rawBody: true,
|
rawBody: true,
|
||||||
snapshot: environmentService.get('DEBUG_MODE'),
|
snapshot: process.env.DEBUG_MODE === 'true',
|
||||||
});
|
});
|
||||||
const logger = app.get(LoggerService);
|
const logger = app.get(LoggerService);
|
||||||
|
|
||||||
@ -64,7 +61,7 @@ const bootstrap = async () => {
|
|||||||
// Create the env-config.js of the front at runtime
|
// Create the env-config.js of the front at runtime
|
||||||
generateFrontConfig();
|
generateFrontConfig();
|
||||||
|
|
||||||
await app.listen(app.get(EnvironmentService).get('PORT'));
|
await app.listen(process.env.PORT ?? 3000);
|
||||||
};
|
};
|
||||||
|
|
||||||
bootstrap();
|
bootstrap();
|
||||||
|
|||||||
@ -1,5 +1,4 @@
|
|||||||
import { NestFactory } from '@nestjs/core';
|
import { NestFactory } from '@nestjs/core';
|
||||||
import { ConfigService } from '@nestjs/config';
|
|
||||||
|
|
||||||
import {
|
import {
|
||||||
MessageQueueJob,
|
MessageQueueJob,
|
||||||
@ -14,17 +13,14 @@ import { MessageQueue } from 'src/engine/integrations/message-queue/message-queu
|
|||||||
import { MessageQueueService } from 'src/engine/integrations/message-queue/services/message-queue.service';
|
import { MessageQueueService } from 'src/engine/integrations/message-queue/services/message-queue.service';
|
||||||
import { getJobClassName } from 'src/engine/integrations/message-queue/utils/get-job-class-name.util';
|
import { getJobClassName } from 'src/engine/integrations/message-queue/utils/get-job-class-name.util';
|
||||||
import { QueueWorkerModule } from 'src/queue-worker/queue-worker.module';
|
import { QueueWorkerModule } from 'src/queue-worker/queue-worker.module';
|
||||||
import { EnvironmentService } from 'src/engine/integrations/environment/environment.service';
|
|
||||||
|
|
||||||
async function bootstrap() {
|
async function bootstrap() {
|
||||||
let exceptionHandlerService: ExceptionHandlerService | undefined;
|
let exceptionHandlerService: ExceptionHandlerService | undefined;
|
||||||
let loggerService: LoggerService | undefined;
|
let loggerService: LoggerService | undefined;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const environmentService = new EnvironmentService(new ConfigService());
|
|
||||||
|
|
||||||
const app = await NestFactory.createApplicationContext(QueueWorkerModule, {
|
const app = await NestFactory.createApplicationContext(QueueWorkerModule, {
|
||||||
bufferLogs: environmentService.get('LOGGER_IS_BUFFER_ENABLED'),
|
bufferLogs: process.env.LOGGER_IS_BUFFER_ENABLED === 'true',
|
||||||
});
|
});
|
||||||
|
|
||||||
loggerService = app.get(LoggerService);
|
loggerService = app.get(LoggerService);
|
||||||
|
|||||||
@ -1,17 +1,14 @@
|
|||||||
import { ConfigService } from '@nestjs/config';
|
|
||||||
|
|
||||||
import * as fs from 'fs';
|
import * as fs from 'fs';
|
||||||
import * as path from 'path';
|
import * as path from 'path';
|
||||||
|
|
||||||
import { EnvironmentService } from 'src/engine/integrations/environment/environment.service';
|
import { config } from 'dotenv';
|
||||||
|
config();
|
||||||
const environmentService = new EnvironmentService(new ConfigService());
|
|
||||||
|
|
||||||
export function generateFrontConfig(): void {
|
export function generateFrontConfig(): void {
|
||||||
const configObject = {
|
const configObject = {
|
||||||
window: {
|
window: {
|
||||||
_env_: {
|
_env_: {
|
||||||
REACT_APP_SERVER_BASE_URL: environmentService.get('SERVER_URL'),
|
REACT_APP_SERVER_BASE_URL: process.env.SERVER_URL,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user