Skip to content

Commit

Permalink
Merge pull request #8 from andreacw5/fix_api_redirect
Browse files Browse the repository at this point in the history
Fix redirect for management api
  • Loading branch information
andreacw5 committed Jan 30, 2023
2 parents 755647e + 020a10c commit d987529
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 2 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "url-manager-app",
"version": "1.0.0",
"version": "1.0.1",
"description": "Url manager system with Rest API for management of short urls, click statistics and redirects by personalized codes",
"author": "Andrea Tombolato <andreacw96@gmail.com> (https://github.com/andreacw5)",
"private": true,
Expand Down
4 changes: 4 additions & 0 deletions src/modules/app/app.controller.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { Controller, Get, Logger, Param, Res } from '@nestjs/common';
import { UrlsService } from '../url/urls.service';
import { ConfigService } from '@nestjs/config';
import { ApiOperation, ApiParam, ApiResponse } from "@nestjs/swagger";

@Controller()
export class AppController {
Expand All @@ -25,6 +26,9 @@ export class AppController {
await res.redirect(this.DEFAULT_REDIRECT_URL);
}

@ApiOperation({ summary: 'Redirect by code' })
@ApiParam({ name: 'code', description: 'The code to redirect' })
@ApiResponse({ status: 200, description: 'Redirect returned' })
@Get('/:code')
async redirectToCode(@Param('code') code, @Res() res) {
this.logger.log(`Redirect to ${code} requested`);
Expand Down
2 changes: 1 addition & 1 deletion src/modules/url/urls.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import { UpdateUrlDTO } from './dto/edit-url-dto';
import { AuthGuard } from '@nestjs/passport';

@ApiTags('urls')
@Controller('urls')
@Controller('/api/urls')
export class UrlsController {
constructor(private readonly urlsService: UrlsService) {}
private readonly logger = new Logger(UrlsController.name);
Expand Down

0 comments on commit d987529

Please sign in to comment.