| 18 | |
| 19 | @ApiUseTag('/* camelName */') |
| 20 | export class /* upperFirstCamelName */Controller { |
| 21 | |
| 22 | @Get() |
| 23 | @ApiOperationId('find/* upperFirstCamelName */s') |
| 24 | @ApiOperationSummary('Find /* camelName */s.') |
| 25 | @ApiOperationDescription( |
| 26 | 'The query parameters "skip" and "take" can be used for pagination. The first ' + |
| 27 | 'is the offset and the second is the number of elements to be returned.' |
| 28 | ) |
| 29 | @ApiResponse(400, { description: 'Invalid query parameters.' }) |
| 30 | @ApiResponse(200, { description: 'Returns a list of /* camelName */s.' }) |
| 31 | @ValidateQueryParam('skip', { type: 'number' }, { required: false }) |
| 32 | @ValidateQueryParam('take', { type: 'number' }, { required: false }) |
| 33 | async find/* upperFirstCamelName */s(ctx: Context) { |
| 34 | const /* camelName */s = await /* upperFirstCamelName */.find({ |
| 35 | skip: ctx.request.query.skip, |
| 36 | take: ctx.request.query.take, |
| 37 | where: {}, |
| 38 | }); |
| 39 | return new HttpResponseOK(/* camelName */s); |
| 40 | } |
| 41 | |
| 42 | @Get('/:/* camelName */Id') |
| 43 | @ApiOperationId('find/* upperFirstCamelName */ById') |
| 44 | @ApiOperationSummary('Find a /* camelName */ by ID.') |
| 45 | @ApiResponse(404, { description: '/* upperFirstCamelName */ not found.' }) |
| 46 | @ApiResponse(200, { description: 'Returns the /* camelName */.' }) |
| 47 | @ValidatePathParam('/* camelName */Id', { type: 'number' }) |
| 48 | async find/* upperFirstCamelName */ById(ctx: Context) { |
| 49 | const /* camelName */ = await /* upperFirstCamelName */.findOneBy({ id: ctx.request.params./* camelName */Id }); |
| 50 | |
| 51 | if (!/* camelName */) { |
| 52 | return new HttpResponseNotFound(); |
| 53 | } |
| 54 | |
| 55 | return new HttpResponseOK(/* camelName */); |
| 56 | } |
| 57 | |
| 58 | @Post() |
| 59 | @ApiOperationId('create/* upperFirstCamelName */') |
| 60 | @ApiOperationSummary('Create a new /* camelName */.') |
| 61 | @ApiResponse(400, { description: 'Invalid /* camelName */.' }) |
| 62 | @ApiResponse(201, { description: '/* upperFirstCamelName */ successfully created. Returns the /* camelName */.' }) |
| 63 | @ValidateBody(/* camelName */Schema) |
| 64 | async create/* upperFirstCamelName */(ctx: Context) { |
| 65 | const /* camelName */ = await /* upperFirstCamelName */.save(ctx.request.body); |
| 66 | return new HttpResponseCreated(/* camelName */); |
| 67 | } |
| 68 | |
| 69 | @Patch('/:/* camelName */Id') |
| 70 | @ApiOperationId('modify/* upperFirstCamelName */') |
| 71 | @ApiOperationSummary('Update/modify an existing /* camelName */.') |
| 72 | @ApiResponse(400, { description: 'Invalid /* camelName */.' }) |
| 73 | @ApiResponse(404, { description: '/* upperFirstCamelName */ not found.' }) |
| 74 | @ApiResponse(200, { description: '/* upperFirstCamelName */ successfully updated. Returns the /* camelName */.' }) |
| 75 | @ValidatePathParam('/* camelName */Id', { type: 'number' }) |
| 76 | @ValidateBody({ .../* camelName */Schema, required: [] }) |
| 77 | async modify/* upperFirstCamelName */(ctx: Context) { |
nothing calls this directly
no test coverage detected