Adds detailed `@ApiBody` schemas to several endpoints within `PageController` and `SpaceController`, including methods for creating and updating pages, spaces, and managing temporary access tokens. This provides clear, machine-readable descriptions of expected request bodies for API consumers. Enables the Swagger UI in the main application bootstrap, allowing for interactive exploration and testing of the API endpoints directly through the browser.
34 lines
1021 B
TypeScript
34 lines
1021 B
TypeScript
|
|
import { NestFactory } from '@nestjs/core';
|
|
import { SwaggerModule, DocumentBuilder, SwaggerCustomOptions } from '@nestjs/swagger';
|
|
import { AppModule } from './app.module';
|
|
|
|
async function bootstrap() {
|
|
const app = await NestFactory.create(AppModule);
|
|
const apiVersion = 1;
|
|
|
|
if (process.env.NODE_ENV === 'dev' || process.env.NODE_ENV === 'test') {
|
|
const config = new DocumentBuilder()
|
|
.setTitle('Gemwiki API')
|
|
.setDescription('The Gemwiki API description')
|
|
.setVersion('1.0')
|
|
.addTag('gemwiki')
|
|
.addServer(`https:/wiki.dahyeon.us/`)
|
|
.addBearerAuth({
|
|
type: 'openIdConnect'
|
|
})
|
|
.build();
|
|
const options: SwaggerCustomOptions = {
|
|
ui: true,
|
|
raw: ['yaml'],
|
|
}
|
|
const documentFactory = () => SwaggerModule.createDocument(app, config);
|
|
SwaggerModule.setup(`v${apiVersion}/api`, app, documentFactory, options);
|
|
}
|
|
|
|
app.setGlobalPrefix(`v${apiVersion}`);
|
|
app.enableCors()
|
|
await app.listen(process.env.PORT ?? 3415);
|
|
}
|
|
bootstrap();
|