@@ -9,9 +9,12 @@ import { version } from "./package.json" with { type: "json" };
99import { z } from "zod/v4" ;
1010import { zodSchemaAdapter } from "./src/adapters/zod-schema-adapter" ;
1111
12+ const EntryId = z . coerce . number ( ) . int ( ) . min ( 0 ) . meta ( { ref : "EntryId" } ) ;
13+ type EntryId = z . infer < typeof EntryId > ;
14+
1215const Entry = z
1316 . object ( {
14- id : z . number ( ) ,
17+ id : EntryId ,
1518 text : z . string ( ) ,
1619 } )
1720 . meta ( {
@@ -84,10 +87,15 @@ const app = createApp({
8487 description : "Create a new entry" ,
8588 tags : [ "Entries" ] ,
8689 body : Entry ,
90+ responses : {
91+ [ HttpStatus . Accepted ] : NoResponse . meta ( {
92+ responseDescription : "Entry created" ,
93+ } ) ,
94+ } ,
8795 } ,
88- ( { body, set } ) => {
96+ ( { body, status } ) => {
8997 entries . push ( body ) ;
90- set . status = HttpStatus . Accepted ;
98+ return status ( HttpStatus . Accepted , undefined ) ;
9199 } ,
92100 )
93101 . get (
@@ -97,7 +105,7 @@ const app = createApp({
97105 summary : "Get entry by ID" ,
98106 description : "Get an entry by ID" ,
99107 tags : [ "Entries" ] ,
100- params : z . object ( { id : z . coerce . number ( ) } ) ,
108+ params : z . object ( { id : EntryId } ) ,
101109 responses : {
102110 [ HttpStatus . Ok ] : Entry ,
103111 [ HttpStatus . NotFound ] : ErrorResponse ,
@@ -117,7 +125,7 @@ const app = createApp({
117125 operationId : "deleteEntry" ,
118126 summary : "Delete Entry" ,
119127 tags : [ "Entries" ] ,
120- params : z . object ( { id : z . coerce . number ( ) } ) ,
128+ params : z . object ( { id : EntryId } ) ,
121129 responses : {
122130 [ HttpStatus . NoContent ] : NoResponse . meta ( {
123131 responseDescription : "Entry deleted" ,
0 commit comments