How to use the @nestjs/platform-express.ExpressAdapter function in @nestjs/platform-express

To help you get started, weโ€™ve selected a few @nestjs/platform-express 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 TimurRK / nestjs-example / src / main.ts View on Github external
async function bootstrap() {
  const server = express();

  const app = await NestFactory.create(AppModule, new ExpressAdapter(server));

  app.use(helmet());
  app.use(cookieParser());
  app.enableCors(corsOptions);

  app.useGlobalPipes(
    new ValidationPipe({
      transform: true,
    })
  );

  // tslint:disable-next-line: no-unsafe-any
  app.useWebSocketAdapter(new WsAdapter(app));

  app.use('/voyager', voyagerMiddleware({ endpointUrl: '/graphql' }));
github visual-knight / platform-community-edition / apps / api / src / index.ts View on Github external
function bootstrapServer(): Promise {
  const expressApp = express();
  const adapter = new ExpressAdapter(expressApp);
  return NestFactory.create(AppModule, adapter)
    .then(app => app.enableCors())
    .then(app => app.init())
    .then(() => serverless.createServer(expressApp));
}
github rdlabo / serverless-nestjs / src / index.ts View on Github external
function bootstrapServer(): Promise {
  const expressApp = express();
  const adapter = new ExpressAdapter(expressApp);
  return NestFactory.create(AppModule, adapter)
    .then(app => app.enableCors())
    .then(app => app.init())
    .then(() => serverless.createServer(expressApp));
}
github magishift / magishift.core / packages / keycloak / src / handler.ts View on Github external
async function bootstrapServer(): Promise {
  if (!cachedServer) {
    try {
      const expressApp = require('express')();

      const adapter = new ExpressAdapter(expressApp);

      const nestApp = await NestFactory.create(KeycloakModule, adapter);

      nestApp.use(eventContext());
      await nestApp.init();

      cachedServer = createServer(expressApp, undefined, binaryMimeTypes);
    } catch (error) {
      return Promise.reject(error);
    }
  }
  return Promise.resolve(cachedServer);
}
github theodo / nestjs-serverless-demo / src / lambda.ts View on Github external
async function bootstrapServer(): Promise {
 if (!cachedServer) {
    const expressApp = express();
    const nestApp = await NestFactory.create(AppModule, new ExpressAdapter(expressApp))
    nestApp.use(eventContext());
    await nestApp.init();
    cachedServer = createServer(expressApp, undefined, binaryMimeTypes);
 }
 return cachedServer;
}
github bazelbuild / rules_nodejs / examples / nestjs / src / main.ts View on Github external
export async function bootstrap(port: number): Promise {
  const app = await NestFactory.create(AppModule, new ExpressAdapter());
  await app.listen(port);
  Logger.log(`Application served at http://localhost:${port}`);
  return app;
}
github Roche / lxdhub / packages / api / src / main.ts View on Github external
private async createNestApp() {
        const nestSettings = { logger: this.logger };

        if (!this.server) {
            this.server = express();
        }

        this.app = await NestFactory.create(
            AppModule.forRoot(this.settings),
            new ExpressAdapter(this.server),
            nestSettings
        );

        this.app.useWebSocketAdapter(new IoAdapter(this.app.getHttpServer()));
    }
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];
}

@nestjs/platform-express

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

MIT
Latest version published 7 days ago

Package Health Score

95 / 100
Full package analysis

Similar packages