Spaces:
Runtime error
Runtime error
| import { | |
| Controller, | |
| Get, | |
| Post, | |
| Delete, | |
| Body, | |
| Param, | |
| Query, | |
| HttpCode, | |
| HttpStatus, | |
| } from '@nestjs/common'; | |
| import { ApiTags, ApiOperation, ApiQuery, ApiParam } from '@nestjs/swagger'; | |
| import { ShlinkService } from './shlink.service'; | |
| import { CreateShortUrlDto } from './dto/shlink.dto'; | |
| import { URL_SHORTENER_PROVIDER } from '@prisma/client'; | |
| import { LogToDiscord } from 'src/shared/decorators/log-to-discord.decorator'; | |
| ('Short URL: Shlink') | |
| ('short-url/shlink') | |
| () | |
| export class ShlinkController { | |
| constructor(private readonly shlinkService: ShlinkService) {} | |
| () | |
| ({ summary: 'Create a new short URL' }) | |
| async createShortUrl(() createDto: CreateShortUrlDto) { | |
| return this.shlinkService.createShortUrl(createDto); | |
| } | |
| () | |
| ({ summary: 'Get all short URLs by provider' }) | |
| ({ | |
| name: 'provider', | |
| enum: URL_SHORTENER_PROVIDER, | |
| required: false, | |
| description: 'Filter by provider (default: SHLINK)', | |
| }) | |
| async getAllShortUrls(('provider') provider?: URL_SHORTENER_PROVIDER) { | |
| return this.shlinkService.getAllShortUrls(provider); | |
| } | |
| (':id') | |
| ({ summary: 'Get a short URL by ID' }) | |
| ({ name: 'id', description: 'Short URL ID' }) | |
| async getShortUrlById(('id') id: string) { | |
| return this.shlinkService.getShortUrlById(id); | |
| } | |
| (':id') | |
| (HttpStatus.OK) | |
| ({ summary: 'Delete a short URL' }) | |
| ({ name: 'id', description: 'Short URL ID' }) | |
| async deleteShortUrl(('id') id: string) { | |
| return this.shlinkService.deleteShortUrl(id); | |
| } | |
| } | |