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.

33 lines
904B

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