Created
September 3, 2023 10:00
-
-
Save DesmondFox/b9a70c0f38d8c1a9e28f2bc54435a573 to your computer and use it in GitHub Desktop.
NestJS and SwaggerUI
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { NestFactory } from '@nestjs/core'; | |
import { ExpressAdapter } from '@nestjs/platform-express'; | |
import * as express from 'express'; | |
import * as functions from 'firebase-functions'; | |
import { AppModule } from './src/app.module'; | |
import { DocumentBuilder, SwaggerModule } from '@nestjs/swagger'; | |
const expressServer = express(); | |
const createFunction = async (expressInstance): Promise<void> => { | |
const app = await NestFactory.create( | |
AppModule, | |
new ExpressAdapter(expressInstance), | |
); | |
const config = new DocumentBuilder() | |
.setTitle('Hello world') | |
.setVersion('1.0') | |
.setDescription("Test description") | |
.build(); | |
const document = SwaggerModule.createDocument(app, config); | |
SwaggerModule.setup('/app', app, document); | |
await app.init(); | |
}; | |
export const api = functions.https.onRequest(async (request, response) => { | |
await createFunction(expressServer); | |
expressServer(request, response); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment