forked from lukeautry/tsoa
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpostController.ts
50 lines (41 loc) · 1.34 KB
/
postController.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
49
50
import { Route } from '../../../src/decorators/route';
import { Post, Patch } from '../../../src/decorators/methods';
import { TestModel, TestClassModel } from '../testModel';
import { ModelService } from '../services/modelService';
@Route('PostTest')
export class PostTestController {
@Post()
public async postModel(model: TestModel): Promise<TestModel> {
return model;
}
@Patch()
public async updateModel(model: TestModel): Promise<TestModel> {
return await new ModelService().getModel();
}
@Post('WithClassModel')
public async postClassModel(model: TestClassModel): Promise<TestClassModel> {
const augmentedModel = new TestClassModel('test', 'test2', 'test3');
augmentedModel.id = 700;
return augmentedModel;
}
@Post('Location')
public async postModelAtLocation(): Promise<TestModel> {
return new ModelService().getModel();
}
@Post('Multi')
public async postWithMultiReturn(): Promise<TestModel[]> {
const model = new ModelService().getModel();
return [
model,
model
];
}
@Post('WithId/{id}')
public async postWithId(id: number): Promise<TestModel> {
return new ModelService().getModel();
}
@Post('WithBodyAndQueryParams')
public async postWithBodyAndQueryParams(model: TestModel, query: string): Promise<TestModel> {
return new ModelService().getModel();
}
}