Skip to content

chore: add swagger docs for ts api #614

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Nov 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
79 changes: 76 additions & 3 deletions lesson_26/api/javascript/api_app/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion lesson_26/api/javascript/api_app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
"@nestjs/common": "^10.0.0",
"@nestjs/core": "^10.0.0",
"@nestjs/platform-express": "^10.0.0",
"@nestjs/swagger": "^8.0.7",
"reflect-metadata": "^0.2.0",
"rxjs": "^7.8.1"
},
Expand Down Expand Up @@ -68,4 +69,4 @@
"coverageDirectory": "../coverage",
"testEnvironment": "node"
}
}
}
11 changes: 11 additions & 0 deletions lesson_26/api/javascript/api_app/src/main.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,22 @@
import { NestFactory } from '@nestjs/core';
import { NestExpressApplication } from '@nestjs/platform-express';
import { DocumentBuilder, SwaggerModule } from '@nestjs/swagger';
import { AppModule } from './app.module';

async function bootstrap() {
const app = await NestFactory.create<NestExpressApplication>(AppModule);
app.enableCors();
app.set('trust proxy', 'loopback'); // Trust requests from the loopback address

const config = new DocumentBuilder()
.setTitle('Library API')
.setDescription('An API for managing a library of media items')
.setVersion('1.0')
.addTag('library')
.build();
const documentFactory = () => SwaggerModule.createDocument(app, config);
SwaggerModule.setup('api', app, documentFactory);

await app.listen(3000);
}

Expand Down
Loading