* feat: restart cmd added in aio service * feat: nestjs config package added * test: fix all broken test case * feat: infra config module add with get-update-reset functionality * test: fix test case failure * feat: update infra configs mutation added * feat: utilise ConfigService in util functions * chore: remove saml stuff * feat: removed saml stuffs * fix: config service precedence * fix: mailer module init with right env value * feat: added mutations and query * feat: add query infra-configs * fix: mailer module init issue * chore: smtp url validation added * fix: all sso disabling is handled * fix: pnpm i without db connection * fix: allowedAuthProviders and enableAndDisableSSO * fix: validateSMTPUrl check * feat: get api added for fetch provider list * feat: feedback resolve * chore: update code comments * fix: uppercase issue of VITE_ALLOWED_AUTH_PROVIDERS * chore: update lockfile * fix: add validation checks for MAILER_ADDRESS_FROM * test: fix test case * chore: feedback resolve * chore: renamed an enum * chore: app shutdown way changed --------- Co-authored-by: Andrew Bastin <andrewbastin.k@gmail.com>
69 lines
1.7 KiB
TypeScript
69 lines
1.7 KiB
TypeScript
import { NestFactory } from '@nestjs/core';
|
|
import { json } from 'express';
|
|
import { AppModule } from './app.module';
|
|
import * as cookieParser from 'cookie-parser';
|
|
import { VersioningType } from '@nestjs/common';
|
|
import * as session from 'express-session';
|
|
import { emitGQLSchemaFile } from './gql-schema';
|
|
import { checkEnvironmentAuthProvider } from './utils';
|
|
import { ConfigService } from '@nestjs/config';
|
|
|
|
async function bootstrap() {
|
|
const app = await NestFactory.create(AppModule);
|
|
|
|
const configService = app.get(ConfigService);
|
|
|
|
console.log(`Running in production: ${configService.get('PRODUCTION')}`);
|
|
console.log(`Port: ${configService.get('PORT')}`);
|
|
|
|
checkEnvironmentAuthProvider(
|
|
configService.get('VITE_ALLOWED_AUTH_PROVIDERS'),
|
|
);
|
|
|
|
app.use(
|
|
session({
|
|
secret: configService.get('SESSION_SECRET'),
|
|
}),
|
|
);
|
|
|
|
// Increase fil upload limit to 50MB
|
|
app.use(
|
|
json({
|
|
limit: '100mb',
|
|
}),
|
|
);
|
|
|
|
if (configService.get('PRODUCTION') === 'false') {
|
|
console.log('Enabling CORS with development settings');
|
|
|
|
app.enableCors({
|
|
origin: configService.get('WHITELISTED_ORIGINS').split(','),
|
|
credentials: true,
|
|
});
|
|
} else {
|
|
console.log('Enabling CORS with production settings');
|
|
|
|
app.enableCors({
|
|
origin: configService.get('WHITELISTED_ORIGINS').split(','),
|
|
credentials: true,
|
|
});
|
|
}
|
|
app.enableVersioning({
|
|
type: VersioningType.URI,
|
|
});
|
|
app.use(cookieParser());
|
|
await app.listen(configService.get('PORT') || 3170);
|
|
|
|
// Graceful shutdown
|
|
process.on('SIGTERM', async () => {
|
|
console.info('SIGTERM signal received');
|
|
await app.close();
|
|
});
|
|
}
|
|
|
|
if (!process.env.GENERATE_GQL_SCHEMA) {
|
|
bootstrap();
|
|
} else {
|
|
emitGQLSchemaFile();
|
|
}
|