feat(storage): add Swagger/OpenAPI documentation

Setup @nestjs/swagger with auto-generated API docs at /api/docs.
Documents all 35 endpoints with bearer auth support.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
Till JS 2026-03-26 13:10:44 +01:00
parent a439d5d8ee
commit 8b5889e125
3 changed files with 506 additions and 481 deletions

View file

@ -30,6 +30,7 @@
"@nestjs/config": "^3.3.0",
"@nestjs/core": "^10.4.15",
"@nestjs/platform-express": "^10.4.15",
"@nestjs/swagger": "^11.2.6",
"@nestjs/throttler": "^6.2.1",
"class-transformer": "^0.5.1",
"class-validator": "^0.14.1",
@ -41,13 +42,11 @@
"rxjs": "^7.8.1"
},
"devDependencies": {
"@nestjs/testing": "^10.4.15",
"@types/jest": "^29.5.0",
"jest": "^30.2.0",
"ts-jest": "^29.4.0",
"@nestjs/cli": "^10.4.9",
"@nestjs/schematics": "^10.2.3",
"@nestjs/testing": "^10.4.15",
"@types/express": "^5.0.0",
"@types/jest": "^29.5.0",
"@types/multer": "^1.4.12",
"@types/node": "^22.10.2",
"@typescript-eslint/eslint-plugin": "^8.18.1",
@ -55,8 +54,10 @@
"eslint": "^9.17.0",
"eslint-config-prettier": "^9.1.0",
"eslint-plugin-prettier": "^5.2.1",
"jest": "^30.2.0",
"prettier": "^3.4.2",
"source-map-support": "^0.5.21",
"ts-jest": "^29.4.0",
"ts-loader": "^9.5.1",
"ts-node": "^10.9.2",
"tsconfig-paths": "^4.2.0",

View file

@ -2,6 +2,7 @@ import './instrument';
import { NestFactory } from '@nestjs/core';
import { ValidationPipe } from '@nestjs/common';
import { ConfigService } from '@nestjs/config';
import { DocumentBuilder, SwaggerModule } from '@nestjs/swagger';
import { AppModule } from './app.module';
async function bootstrap() {
@ -26,8 +27,19 @@ async function bootstrap() {
})
);
// Swagger API docs
const swaggerConfig = new DocumentBuilder()
.setTitle('Storage API')
.setDescription('Cloud storage service — files, folders, shares, tags, trash')
.setVersion('1.0')
.addBearerAuth()
.build();
const document = SwaggerModule.createDocument(app, swaggerConfig);
SwaggerModule.setup('api/docs', app, document);
await app.listen(port);
console.log(`Storage backend running on http://localhost:${port}`);
console.log(`Swagger docs at http://localhost:${port}/api/docs`);
}
bootstrap();

966
pnpm-lock.yaml generated

File diff suppressed because it is too large Load diff