feat: API versioning, compound indexes, and new exports
- Add global /api/v1/ prefix with health/ready exclusions - Add compound indexes on Property and Listing for query optimization - Export CsrfMiddleware and UploadedFile type from shared infra - New Prisma migration for compound indexes Co-Authored-By: Paperclip <noreply@paperclip.ing>
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
import './instrument';
|
||||
|
||||
import { ValidationPipe } from '@nestjs/common';
|
||||
import { RequestMethod, ValidationPipe } from '@nestjs/common';
|
||||
import { NestFactory } from '@nestjs/core';
|
||||
import { DocumentBuilder, SwaggerModule } from '@nestjs/swagger';
|
||||
import cookieParser from 'cookie-parser';
|
||||
@@ -18,6 +18,14 @@ async function bootstrap() {
|
||||
const logger = app.get(LoggerService);
|
||||
app.useLogger(logger);
|
||||
|
||||
// ── API Versioning — global /api/v1/ prefix ──
|
||||
app.setGlobalPrefix('api/v1', {
|
||||
exclude: [
|
||||
{ path: 'health', method: RequestMethod.GET },
|
||||
{ path: 'ready', method: RequestMethod.GET },
|
||||
],
|
||||
});
|
||||
|
||||
// ── OpenAPI / Swagger ──
|
||||
const swaggerConfig = new DocumentBuilder()
|
||||
.setTitle('Goodgo Platform API')
|
||||
@@ -37,7 +45,7 @@ async function bootstrap() {
|
||||
.addTag('analytics', 'Market reports & price analytics')
|
||||
.build();
|
||||
const document = SwaggerModule.createDocument(app, swaggerConfig);
|
||||
SwaggerModule.setup('api/docs', app, document, {
|
||||
SwaggerModule.setup('api/v1/docs', app, document, {
|
||||
swaggerOptions: { persistAuthorization: true },
|
||||
});
|
||||
|
||||
@@ -108,7 +116,7 @@ async function bootstrap() {
|
||||
|
||||
const port = process.env['PORT'] ?? 3001;
|
||||
await app.listen(port);
|
||||
logger.log(`API running on http://localhost:${port}`, 'Bootstrap');
|
||||
logger.log(`API running on http://localhost:${port}/api/v1`, 'Bootstrap');
|
||||
}
|
||||
|
||||
bootstrap();
|
||||
|
||||
@@ -7,8 +7,9 @@ export { GlobalExceptionFilter } from './filters/global-exception.filter';
|
||||
export { CorrelationIdMiddleware } from './middleware/correlation-id.middleware';
|
||||
export { RequestLoggingMiddleware } from './middleware/request-logging.middleware';
|
||||
export { SanitizeInputMiddleware } from './middleware/sanitize-input.middleware';
|
||||
export { CsrfMiddleware } from './middleware/csrf.middleware';
|
||||
export { maskPii } from './pii-masker';
|
||||
export { ThrottlerBehindProxyGuard } from './guards/throttler-behind-proxy.guard';
|
||||
export { FileValidationPipe } from './pipes/file-validation.pipe';
|
||||
export type { FileValidationOptions } from './pipes/file-validation.pipe';
|
||||
export type { FileValidationOptions, UploadedFile } from './pipes/file-validation.pipe';
|
||||
export { validateEnv, validateJwtSecret } from './env-validation';
|
||||
|
||||
Reference in New Issue
Block a user