Skip to content

📈 Open source, privacy-first web analytics — a cookie-less Google Analytics alternative with built-in error tracking and performance monitoring. Self-host it or use our cloud. Get started for free!

added swagger for the dev environment

Blue Mouse5d997eab8e70
diff --git a/src/main.ts b/src/main.ts
index 837fa0624..8f33f3d39 100644
--- a/src/main.ts
+++ b/src/main.ts
@@ -2,6 +2,7 @@ import { NestFactory } from '@nestjs/core'
import { ValidationPipe } from '@nestjs/common'
import * as cookieParser from 'cookie-parser'
import * as bodyParser from 'body-parser'
+import { SwaggerModule, DocumentBuilder } from '@nestjs/swagger'
import { isNewRelicEnabled } from './common/constants'
import { AppModule } from './app.module'
@@ -12,6 +13,16 @@ async function bootstrap() {
app.use(cookieParser())
app.useGlobalPipes(new ValidationPipe())
+ if (process.env.NODE_ENV === 'development') {
+ const config = new DocumentBuilder()
+ .setTitle('Swetrix API')
+ .setDescription('Swetrix Analytics & Marketplace API')
+ .setVersion(process.env.npm_package_version)
+ .build()
+ const document = SwaggerModule.createDocument(app, config)
+ SwaggerModule.setup('api', app, document)
+ }
+
if (isNewRelicEnabled && process.env.NODE_ENV !== 'development') {
app.useGlobalInterceptors(new NewrelicInterceptor())
}