feat: bootstrap NestJS backend with auth, stations, users, health-check, now-playing

This commit is contained in:
nk
2026-06-02 13:54:00 +03:00
commit 8aadd62e3c
47 changed files with 13234 additions and 0 deletions

View File

@@ -0,0 +1,70 @@
import {
Controller,
Get,
Post,
Patch,
Delete,
Body,
Param,
Query,
UseGuards,
HttpCode,
HttpStatus,
} from '@nestjs/common';
import { ApiTags, ApiOperation, ApiBearerAuth } from '@nestjs/swagger';
import { StationsService } from './stations.service';
import { CreateStationDto } from './dto/create-station.dto';
import { UpdateStationDto } from './dto/update-station.dto';
import { AuthGuard } from '../auth/auth.guard';
@ApiTags('stations')
@Controller('stations')
export class StationsController {
constructor(private readonly stationsService: StationsService) {}
@Get()
@ApiOperation({ summary: 'List all stations' })
async findAll(
@Query('search') search?: string,
@Query('source') source?: string,
@Query('online') online?: string,
) {
return this.stationsService.findAll({
search,
source,
online: online === 'true' ? true : online === 'false' ? false : undefined,
});
}
@Get(':id')
@ApiOperation({ summary: 'Get station by ID' })
async findOne(@Param('id') id: string) {
return this.stationsService.findOne(id);
}
@Post()
@UseGuards(AuthGuard)
@ApiBearerAuth()
@ApiOperation({ summary: 'Create station (admin)' })
@HttpCode(HttpStatus.CREATED)
async create(@Body() dto: CreateStationDto) {
return this.stationsService.create(dto);
}
@Patch(':id')
@UseGuards(AuthGuard)
@ApiBearerAuth()
@ApiOperation({ summary: 'Update station (admin)' })
async update(@Param('id') id: string, @Body() dto: UpdateStationDto) {
return this.stationsService.update(id, dto);
}
@Delete(':id')
@UseGuards(AuthGuard)
@ApiBearerAuth()
@ApiOperation({ summary: 'Delete station (admin)' })
@HttpCode(HttpStatus.NO_CONTENT)
async remove(@Param('id') id: string) {
await this.stationsService.remove(id);
}
}