How to use the @nestjs/core.NestFactory.create function in @nestjs/core

To help you get started, we’ve selected a few @nestjs/core examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github new-eden-social / new-eden-social / src / services / post / server.ts View on Github external
async function bootstrap() {
  const HTTP_PORT = parseInt(process.env.HTTP_PORT, 10) || 3000; // Default to 3000
  const GRPC_PORT = parseInt(process.env.GRPC_PORT, 10) || 4000; // Default to 4000

  const app = await NestFactory.create(PostModule);

  app.connectMicroservice({
    transport: Transport.GRPC,
    options: {
      url: `0.0.0.0:${GRPC_PORT}`,
      package: 'post',
      protoPath: join(__dirname, 'src/grpc/post.proto'),
    },
  });

  app.connectMicroservice({
    transport: Transport.REDIS,
    options: {
      url: process.env.REDIS_HOST,
    },
  });
github new-eden-social / new-eden-social / src / services / search / server.ts View on Github external
async function bootstrap() {
  const HTTP_PORT = parseInt(process.env.HTTP_PORT, 10) || 3000; // Default to 3000
  const GRPC_PORT = parseInt(process.env.GRPC_PORT, 10) || 4000; // Default to 4000

  const app = await NestFactory.create(SearchModule);

  app.connectMicroservice({
    transport: Transport.GRPC,
    options: {
      url: `0.0.0.0:${GRPC_PORT}`,
      package: 'search',
      protoPath: join(__dirname, 'src/grpc/search.proto'),
    },
  });

  await app.startAllMicroservicesAsync();
  await app.listen(HTTP_PORT);
}
github Abdallah-khalil / ContactManagerApp / src / server / index.ts View on Github external
async function bootstrap() {
    const app = await NestFactory.create(ApplicationModule, expressApp);
    app.setGlobalPrefix('api');
    app.use(cors());
    app.use(bodyParser.json());
    app.use(expressJWT({ secret: process.env.JWT_SWECRET }).unless({ path: '/api/auth/authenticate' }), (error, req, res, next) => {
        if (error.name === 'UnauthorizedError') {
            res.status(HttpStatus.UNAUTHORIZED).json({
                message: error.message
            });
        }
    });
    await app.listen(process.env.PORT, () => {
        console.log('APP is listening on port ' + process.env.PORT);
    });
}
bootstrap();
github ZhiXiao-Lin / nestify / examples / 05-rule-engine / src / main.ts View on Github external
async function bootstrap() {
  const app = await NestFactory.create(AppModule);

  const ruleEngine = app.get(RuleEngineService);

  const rules = [];
  rules.push(ruleEngine.register(TestRule));

  rules.push(
    new RuleBuilder()
      .name('test2')
      .priority(1)
      .when(async () => true)
      .then(async () => console.log('test2 action'))
      .build(),
  );

  await ruleEngine.fire(rules, { value: 'test' });
github mentos1386 / lynx / src / server.ts View on Github external
async function bootstrap(): Promise {
  config();
  const instance = express();

  instance.use(cors());
  instance.use('/uploads', express.static('uploads'));

  const nestApp = await NestFactory.create(ApplicationModule, instance);
  nestApp.useGlobalInterceptors(new ResponseInterceptor());
  nestApp.useGlobalFilters(new RequestExceptionFilter(), new DefaultExceptionFilter());
  nestApp.useGlobalPipes(new ValidatorPipe());
  nestApp.useGlobalGuards(new RolesGuard(new Reflector()));

  const server = await nestApp.listen(parseInt(process.env.API_PORT, 10));
  console.info(`Application is listening on port ${process.env.API_PORT}.`);
  return server;
}
github nestjs / nest / sample / 07-sequelize / src / main.ts View on Github external
async function bootstrap() {
  const app = await NestFactory.create(AppModule);
  await app.listen(3000);
}
bootstrap();
github Shyam-Chen / Angular-Starter / src / server.ts View on Github external
async function bootstrap() {
  const app = await NestFactory.create(ApiModule);
  await app.listen(3000);
}
github TheAifam5 / nestjs-docker-microservices / microservices / gateway / src / main.ts View on Github external
async function bootstrap() {
  const app = await NestFactory.create(AppModule);
  await app.listen(3002);
}
bootstrap();
github theodo / nestjs-serverless-demo / src / main.ts View on Github external
async function bootstrap() {
  const app = await NestFactory.create(AppModule);
  await app.listen(3000);
}
bootstrap();
github zifahm / nestjs-voting-app / packages / server / src / main.ts View on Github external
async function bootstrap() {
  const RedisStore = Store(session);

  const app = await NestFactory.create(AppModule);
  app.use(
    session({
      store: new RedisStore({
        client: redis as any,
      }),
      name: 'votingapp',
      secret: SESSION_SECRET,
      resave: false,
      saveUninitialized: false,
      cookie: {
        httpOnly: true,
        secure: process.env.NODE_ENV === 'production',
        expires: true,
        maxAge: 1000 * 60 * 60 * 24 * 365,
      },
    }),