@@ -14,60 +14,60 @@ export const app = new Elysia()
1414 } )
1515 } )
1616 )
17+ . get (
18+ '/const' ,
19+ ( ) =>
20+ ( {
21+ name : 'Lilith' ,
22+ friends : [ 'Sartre' , 'Fouco' ]
23+ } ) as const
24+ )
1725 . model ( {
1826 'character.name' : t . String ( ) ,
1927 'character.thing' : t . Object ( {
2028 name : t . String ( )
2129 } )
2230 } )
2331 . get (
24- '/const ' ,
32+ '/' ,
2533 ( ) =>
26- ( {
27- name : 'Lilith' ,
28- friends : [ 'Sartre' , 'Fouco' ]
34+ ( { test : 'hello' as const } ) as any as
35+ | { test : 'hello' }
36+ | undefined ,
37+ {
38+ response : {
39+ 204 : withHeaders (
40+ t . Void ( {
41+ title : 'Thing' ,
42+ description : 'Void response'
43+ } ) ,
44+ {
45+ 'X-Custom-Header' : t . Literal ( 'Elysia' )
46+ }
47+ )
48+ }
49+ }
50+ )
51+ . post (
52+ '/json' ,
53+ ( { body, status } ) => ( Math . random ( ) > 0.5 ? status ( 418 ) : body ) ,
54+ {
55+ body : t . Object ( {
56+ hello : t . String ( )
57+ } )
58+ }
59+ )
60+ . get ( '/id/:id/name/:name' , ( { params } ) => params )
61+ . post (
62+ '/character' ,
63+ ( ) => ( {
64+ name : 'Lilith' as const
65+ } ) ,
66+ {
67+ body : 'character.name' ,
68+ response : z . object ( {
69+ name : z . literal ( 'Lilith' )
2970 } )
71+ }
3072 )
31- // .get(
32- // '/',
33- // () =>
34- // ({ test: 'hello' as const }) as any as
35- // | { test: 'hello' }
36- // | undefined,
37- // {
38- // response: {
39- // 204: withHeaders(
40- // t.Void({
41- // title: 'Thing',
42- // description: 'Void response'
43- // }),
44- // {
45- // 'X-Custom-Header': t.Literal('Elysia')
46- // }
47- // )
48- // }
49- // }
50- // )
51- // .post(
52- // '/json',
53- // ({ body, status }) => (Math.random() > 0.5 ? status(418) : body),
54- // {
55- // body: t.Object({
56- // hello: t.String()
57- // })
58- // }
59- // )
60- // .get('/id/:id/name/:name', ({ params }) => params)
61- // .post(
62- // '/character',
63- // () => ({
64- // name: 'Lilith' as const
65- // }),
66- // {
67- // body: 'character.name',
68- // response: z.object({
69- // name: z.literal('Lilith')
70- // })
71- // }
72- // )
7373 . listen ( 3000 )
0 commit comments