@@ -203,7 +203,7 @@ export const SessionApi = HttpApi.make("session")
203203 } ) ,
204204 ) ,
205205 HttpApiEndpoint . post ( "create" , SessionPaths . create , {
206- payload : Session . CreateInput ,
206+ payload : [ HttpApiSchema . NoContent , Session . CreateInput ] ,
207207 success : Session . Info ,
208208 } ) . annotateMerge (
209209 OpenApi . annotations ( {
@@ -513,7 +513,7 @@ export const sessionHandlers = Layer.unwrap(
513513 )
514514 } )
515515
516- const create = Effect . fn ( "SessionHttpApi.create" ) ( function * ( ctx : { payload : Session . CreateInput } ) {
516+ const create = Effect . fn ( "SessionHttpApi.create" ) ( function * ( ctx : { payload ? : Session . CreateInput } ) {
517517 const instance = yield * InstanceState . context
518518 return yield * Effect . promise ( ( ) =>
519519 Instance . restore ( instance , ( ) =>
@@ -524,6 +524,22 @@ export const sessionHandlers = Layer.unwrap(
524524 )
525525 } )
526526
527+ const createRaw = Effect . fn ( "SessionHttpApi.createRaw" ) ( function * ( ctx : {
528+ request : HttpServerRequest . HttpServerRequest
529+ } ) {
530+ const body = yield * Effect . orDie ( ctx . request . text )
531+ if ( body . trim ( ) . length === 0 ) return yield * create ( { } )
532+
533+ const json = yield * Effect . try ( {
534+ try : ( ) => JSON . parse ( body ) as unknown ,
535+ catch : ( ) => new HttpApiError . BadRequest ( { } ) ,
536+ } )
537+ const payload = yield * Schema . decodeUnknownEffect ( Session . CreateInput ) ( json ) . pipe (
538+ Effect . mapError ( ( ) => new HttpApiError . BadRequest ( { } ) ) ,
539+ )
540+ return yield * create ( { payload } )
541+ } )
542+
527543 const remove = Effect . fn ( "SessionHttpApi.remove" ) ( function * ( ctx : { params : { sessionID : SessionID } } ) {
528544 const instance = yield * InstanceState . context
529545 yield * Effect . promise ( ( ) =>
@@ -894,7 +910,7 @@ export const sessionHandlers = Layer.unwrap(
894910 . handle ( "diff" , diff )
895911 . handle ( "messages" , messages )
896912 . handle ( "message" , message )
897- . handle ( "create" , create )
913+ . handleRaw ( "create" , createRaw )
898914 . handle ( "remove" , remove )
899915 . handle ( "update" , update )
900916 . handle ( "fork" , fork )
0 commit comments