forked from lukeautry/tsoa
-
Notifications
You must be signed in to change notification settings - Fork 0
/
noSecurityController.ts
30 lines (26 loc) · 1022 Bytes
/
noSecurityController.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
import { Get, Request, Response, Route, Security, NoSecurity } from '@tsoa/runtime';
import { ErrorResponseModel, UserResponseModel } from '../../fixtures/testModel';
interface RequestWithUser {
user?: any;
}
@Security('tsoa_auth', ['write:pets', 'read:pets'])
@Route('NoSecurityTest')
export class NoSecurityTestController {
@Response<ErrorResponseModel>('default', 'Unexpected error')
@Security('api_key')
@Get()
public async GetWithApi(@Request() request: RequestWithUser): Promise<UserResponseModel> {
return Promise.resolve(request.user);
}
@Response<ErrorResponseModel>('404', 'Not Found')
@Get('Oauth')
public async GetWithImplicitSecurity(@Request() request: RequestWithUser): Promise<UserResponseModel> {
return Promise.resolve(request.user);
}
@Response<ErrorResponseModel>('404', 'Not Found')
@Get('Anonymous')
@NoSecurity()
public async GetWithNoSecurity(@Request() request: RequestWithUser): Promise<UserResponseModel> {
return Promise.resolve(request.user);
}
}