-
Notifications
You must be signed in to change notification settings - Fork 1.1k
/
todo-list-image.controller.ts
48 lines (44 loc) · 1.42 KB
/
todo-list-image.controller.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
// Copyright IBM Corp. 2018. All Rights Reserved.
// Node module: @loopback/example-todo-list
// This file is licensed under the MIT License.
// License text available at https://opensource.org/licenses/MIT
import {repository} from '@loopback/repository';
import {get, getModelSchemaRef, param, post, requestBody} from '@loopback/rest';
import {TodoListImage} from '../models';
import {TodoListRepository} from '../repositories';
export class TodoListImageController {
constructor(
@repository(TodoListRepository) protected todoListRepo: TodoListRepository,
) {}
@post('/todo-lists/{id}/image', {
responses: {
'200': {
description: 'create todoListImage model instance',
content: {
'application/json': {schema: getModelSchemaRef(TodoListImage)},
},
},
},
})
async create(
@param.path.number('id') id: number,
@requestBody() image: TodoListImage,
): Promise<TodoListImage> {
return await this.todoListRepo.image(id).create(image);
}
@get('/todo-lists/{id}/image', {
responses: {
'200': {
description: 'The image belonging to the TodoList',
content: {
'application/json': {
schema: getModelSchemaRef(TodoListImage, {includeRelations: true}),
},
},
},
},
})
async find(@param.path.number('id') id: number): Promise<TodoListImage> {
return await this.todoListRepo.image(id).get();
}
}