You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

35 line
974B

  1. import { NestFactory } from '@nestjs/core';
  2. import { AppModule } from './app.module';
  3. import { db } from './db';
  4. import { initDB } from './init';
  5. import { SERVERDATA } from './config';
  6. import { PubSub } from 'graphql-subscriptions';
  7. import {NestExpressApplication} from '@nestjs/platform-express'
  8. export const pubsub = new PubSub();
  9. async function bootstrap(argv: string[]) {
  10. await db.connect();
  11. await initDB(argv.findIndex(a => a.toLowerCase() === 'init') !== -1, argv.findIndex(a => a.toLowerCase() === 'reset') !== -1);
  12. const app = await NestFactory.create<NestExpressApplication>(AppModule);
  13. await app.listen(SERVERDATA.port, SERVERDATA.listen);
  14. }
  15. let args: string[];
  16. if (process.env.npm_config_argv) {
  17. args = JSON.parse(process.env.npm_config_argv || '').remain || [];
  18. } else {
  19. args = process.argv.slice(2);
  20. }
  21. process.on('uncaughtException', (error) => {
  22. // tslint:disable-next-line:no-console
  23. console.error(error);
  24. });
  25. bootstrap(args).then();