| 14 | import { initializeTests } from './init'; |
| 15 | |
| 16 | @Controller('/test') |
| 17 | class TestController extends ApiController { |
| 18 | @HttpGet('/toBoolean') |
| 19 | toBoolean(@QueryParam(toBoolean) val: boolean): any { |
| 20 | return { data: val }; |
| 21 | } |
| 22 | @HttpGet('/toInteger') |
| 23 | toInteger(@QueryParam(toInteger) val: number): any { |
| 24 | return { data: val }; |
| 25 | } |
| 26 | @HttpGet('/toNumber') |
| 27 | toNumber(@QueryParam(toNumber) val: number): any { |
| 28 | return { data: val }; |
| 29 | } |
| 30 | // Verify without handler |
| 31 | @HttpGet('/query') |
| 32 | query(@QueryParam() search: string): any { |
| 33 | return { data: search }; |
| 34 | } |
| 35 | // Verify with, without parse and with, without handler in query-param |
| 36 | @HttpGet('/:user/:id') |
| 37 | userImg( |
| 38 | @Parse(toNumber) id: number, |
| 39 | user: string, |
| 40 | @QueryParam() price: string, |
| 41 | @QueryParam(toBoolean) old: boolean): any { |
| 42 | return { id: id, user: user, price: price, old: old }; |
| 43 | } |
| 44 | @HttpPost('/add/:user/:id') |
| 45 | addParse( |
| 46 | @Parse(() => 'test_body') body: any, |
| 47 | @Parse(() => 'test_user') user: string, |
| 48 | id: string, |
| 49 | @QueryParam() price: string, |
| 50 | @QueryParam(toBoolean) old: boolean): any { |
| 51 | return { |
| 52 | body: body, |
| 53 | user: user, |
| 54 | id: id, |
| 55 | price: price, |
| 56 | old: old |
| 57 | }; |
| 58 | } |
| 59 | } |
| 60 | describe('query.param.e2e.spec', () => { |
| 61 | const baseRoute = '/api/test'; |
| 62 |
nothing calls this directly
no test coverage detected