Add show crud

Basically the result of running nest g resource shows --no-spec
I did add the schema manually, and removed the update dto
This commit is contained in:
Toast 2025-01-21 21:22:31 +01:00
parent f9c337239f
commit 916d3fd6ba
7 changed files with 84 additions and 1 deletions

View file

@ -3,9 +3,14 @@ import { AppController } from './app.controller';
import { AppService } from './app.service';
import { ConfigModule } from '@nestjs/config';
import { MongooseModule } from '@nestjs/mongoose';
import { ShowsModule } from './shows/shows.module';
@Module({
imports: [ConfigModule.forRoot(), MongooseModule.forRoot(process.env.URI)],
imports: [
ConfigModule.forRoot(),
MongooseModule.forRoot(process.env.URI),
ShowsModule,
],
controllers: [AppController],
providers: [AppService],
})

View file

@ -0,0 +1 @@
export class ShowDto {}

View file

@ -0,0 +1 @@
export class Show {}

View file

@ -0,0 +1 @@
export class ShowSchema {}

View file

@ -0,0 +1,41 @@
import {
Controller,
Get,
Post,
Body,
Patch,
Param,
Delete,
} from '@nestjs/common';
import { ShowsService } from './shows.service';
import { ShowDto } from './dto/show.dto';
@Controller('shows')
export class ShowsController {
constructor(private readonly showsService: ShowsService) {}
@Post()
create(@Body() dto: ShowDto) {
return this.showsService.create(dto);
}
@Get()
findAll() {
return this.showsService.findAll();
}
@Get(':id')
findOne(@Param('id') id: string) {
return this.showsService.findOne(+id);
}
@Patch(':id')
update(@Param('id') id: string, @Body() dto: ShowDto) {
return this.showsService.update(+id, dto);
}
@Delete(':id')
remove(@Param('id') id: string) {
return this.showsService.remove(+id);
}
}

View file

@ -0,0 +1,9 @@
import { Module } from '@nestjs/common';
import { ShowsService } from './shows.service';
import { ShowsController } from './shows.controller';
@Module({
controllers: [ShowsController],
providers: [ShowsService],
})
export class ShowsModule {}

View file

@ -0,0 +1,25 @@
import { Injectable } from '@nestjs/common';
import { ShowDto } from './dto/show.dto';
@Injectable()
export class ShowsService {
create(dto: ShowDto) {
return 'This action adds a new show';
}
findAll() {
return `This action returns all shows`;
}
findOne(id: number) {
return `This action returns a #${id} show`;
}
update(id: number, dto: ShowDto) {
return `This action updates a #${id} show`;
}
remove(id: number) {
return `This action removes a #${id} show`;
}
}