Skip to content

Commit

Permalink
swagger improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
mishraomp committed Sep 4, 2024
1 parent 1885fd3 commit b596f78
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 15 deletions.
4 changes: 2 additions & 2 deletions backend/src/app.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ import {Body, Controller, Get, HttpException, HttpStatus, Logger, Param, Post, R
import {AppService} from './app.service';
import {UrlShortenDTO} from "./dto/url.shorten";
import {Response} from "express";
import * as process from "node:process";
import {ApiExcludeEndpoint} from "@nestjs/swagger";
import {ApiExcludeEndpoint, ApiTags} from "@nestjs/swagger";
import {escape, isAlphanumeric, isURL} from "validator";
@ApiTags('turl')
@Controller()
export class AppController {
private logger = new Logger("AppController");
Expand Down
32 changes: 19 additions & 13 deletions backend/src/app.ts
Original file line number Diff line number Diff line change
@@ -1,30 +1,36 @@
import { NestFactory } from '@nestjs/core';
import { DocumentBuilder, SwaggerModule } from '@nestjs/swagger';
import { AppModule } from './app.module';
import { NestExpressApplication } from '@nestjs/platform-express';
import {NestFactory} from '@nestjs/core';
import {DocumentBuilder, SwaggerModule} from '@nestjs/swagger';
import {AppModule} from './app.module';
import {NestExpressApplication} from '@nestjs/platform-express';
import helmet from 'helmet';
import { VersioningType } from '@nestjs/common';
import { metricsMiddleware } from "./prom";
import {metricsMiddleware} from "./prom";
import * as process from "node:process";

/**
*
*/
export async function bootstrap() {
const app: NestExpressApplication =
await NestFactory.create<NestExpressApplication>(AppModule,{});
await NestFactory.create<NestExpressApplication>(AppModule, {});
app.use(helmet());
app.enableCors();
app.set("trust proxy", 1);
app.use(metricsMiddleware);
app.enableShutdownHooks();
app.enableVersioning({
type: VersioningType.URI,
prefix: "v",
});
const tinyURLDescription = `### What is TURL?
TURL(Tiny URL) is a URL shortening service that allows users to shorten long URLs into short URLs. It is a simple and easy-to-use service that can be used to shorten URLs for sharing in emails, or in any other situation where a long URL is not ideal.`;



const config = new DocumentBuilder()
.setTitle("TURL")
.setDescription("Tiny URL as a Service")
.setVersion("1.0")
.setDescription(tinyURLDescription)
.setContact(
"NRIDS Architects & FDS Devops",
"",
""
)
.addServer(process.env.APP_URL || "http://localhost:3000/")
.addTag("turl")
.build();

Expand Down

0 comments on commit b596f78

Please sign in to comment.