How to use @nestjs/platform-fastify - 7 common examples

To help you get started, we’ve selected a few @nestjs/platform-fastify 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 Javen205 / TNWX / example / nest / src / main.ts View on Github external
async function bootstrap() {
  // 亦可以读取配置文件
  let apiConfig = new ApiConfig("Javen", "wx614c453e0d1dcd12", "19a02e4927d346484fc70327970457f9", false, "xxxx");
  // 支持多公众号
  ApiConfigKit.putApiConfig(apiConfig);
  ApiConfigKit.setCurrentAppId();
  // 开启开发模式,方便调试
  ApiConfigKit.devMode = true;

  const app = await NestFactory.create(
    AppModule,
    new FastifyAdapter(),
  );
  console.log("__dirname:", __dirname);

  app.useStaticAssets({
    root: join(__dirname, 'public'),
    prefix: '/public/',
  });
  app.setViewEngine({
    engine: {
      handlebars: require('handlebars'),
    },
    templates: join(__dirname, 'views'),
  });
  await app.listen(8888);
}
bootstrap();
github ZhiXiao-Lin / nestify / server / src / main.ts View on Github external
async function bootstrap() {
    const nextjs = Nextjs({ dev });
    await nextjs.prepare();

    // Nestjs
    const app = await NestFactory.create(
        AppModule,
        new FastifyAdapter(await initFastify(nextjs)),
        {
            logger: false
        }
    );

    await initScripts(app);
    await initSwagger(app);

    app.enableCors();
    app.useGlobalFilters(new ExceptionsFilter());

    await mq.init();
    await wf.init();

    io.server.listen(app.getHttpServer());
    await io.init();
github jmcdo29 / zeldaPlay / src / server / main.ts View on Github external
async function bootstrap() {
  try {
    const app = await NestFactory.create(
      AppServerModule,
      new FastifyAdapter(),
      {
        logger: new MyLogger()
      }
    );
    configure(app);
    await app.listen(PORT, HOST);
    MyLogger.log(`Application stated on ${HOST}:${PORT}.`, 'Main');
  } catch (err) {
    MyLogger.error(err.message, err.stack, 'Main');
    process.exit(0);
  }
}
github nestjs / nest / sample / 17-mvc-fastify / src / main.ts View on Github external
async function bootstrap() {
  const app = await NestFactory.create(
    ApplicationModule,
    new FastifyAdapter(),
  );
  app.useStaticAssets({
    root: join(__dirname, '..', 'public'),
    prefix: '/public/',
  });
  app.setViewEngine({
    engine: {
      handlebars: require('handlebars'),
    },
    templates: join(__dirname, '..', 'views'),
  });
  await app.listen(3000);
}
bootstrap();
github juicycleff / ultimate-backend / apps / service-notification / src / main.ts View on Github external
async function bootstrap() {
  const app = await NestFactory.create(
    AppModule,
    new FastifyAdapter(),
  );

  app.enableCors({
    credentials: true,
    preflightContinue: true,
  });
  app.enableShutdownHooks();
  app.use(bloodTearsMiddleware);

  await app.listenAsync(
    parseInt(process.env.PORT, 10) ||
    parseInt(config.services?.notification?.port, 10) ||
    9400,
  );
}
bootstrap();
github nestjs / terminus / e2e / helper / bootstrap-module.ts View on Github external
export async function bootstrapModule(
  options: TerminusModuleAsyncOptions,
  useDb: boolean = false,
  useMongoose: boolean = false,
  useFastify?: boolean,
  tcpPort?: number,
): Promise<[INestApplication, number]> {
  const app = await NestFactory.create(
    ApplicationModule.forRoot(options, useDb, useMongoose),
    useFastify ? new FastifyAdapter() : new ExpressAdapter(),
  );

  if (tcpPort) {
    await bootstrapMicroservice(tcpPort);
  }

  const port = await portfinder.getPortPromise({
    port: 3000,
    stopPort: 8888,
  });
  await app.listen(port, '0.0.0.0');
  return [app, port];
}
github nestjs / nest / sample / 10-fastify / src / main.ts View on Github external
async function bootstrap() {
  const app = await NestFactory.create(
    AppModule,
    new FastifyAdapter(),
  );
  app.useGlobalPipes(new ValidationPipe());
  await app.listen(3000);
}
bootstrap();

@nestjs/platform-fastify

Nest - modern, fast, powerful node.js web framework (@platform-fastify)

MIT
Latest version published 13 days ago

Package Health Score

98 / 100
Full package analysis

Popular @nestjs/platform-fastify functions

Similar packages