@@ -42,28 +42,28 @@ const get = (
4242} ;
4343
4444app . post ( "/create" , async ( c ) => {
45- const userIdCookie = getCookie ( c , "userId" ) ;
46- if ( ! userIdCookie ) return c . json ( { } ) ;
45+ const userId = getCookie ( c , "userId" ) ;
46+ if ( ! userId ) return c . text ( "No userId" ) ;
4747 const data = await c . req . json < TModel > ( ) ;
48- create ( userIdCookie , data ) ;
48+ create ( userId , data ) ;
4949 return c . json ( {
50- user : userIdCookie ,
50+ user : userId ,
5151 ...data ,
5252 } ) ;
5353} ) ;
5454
5555app . post ( "/clear" , ( c ) => {
56- const userIdCookie = getCookie ( c , "userId" ) ;
57- if ( ! userIdCookie ) return c . json ( { } ) ;
58- clear ( userIdCookie ) ;
59- return c . json ( { cookie : userIdCookie } ) ;
56+ const userId = getCookie ( c , "userId" ) ;
57+ if ( ! userId ) return c . text ( "No userId" ) ;
58+ clear ( userId ) ;
59+ return c . json ( { cookie : userId } ) ;
6060} ) ;
6161
6262app . all ( "/api/*" , async ( c ) => {
63- const userIdCookie = getCookie ( c , "userId" ) ;
64- if ( ! userIdCookie ) return c . json ( { } ) ;
63+ const userId = getCookie ( c , "userId" ) ;
64+ if ( ! userId ) return c . text ( "No userId" ) ;
6565 const path = c . req . path . replace ( "/api" , "" ) ;
66- const redisData = await get ( userIdCookie , c . req . method , path ) ;
66+ const redisData = await get ( userId , c . req . method , path ) ;
6767 if ( ! redisData ) return c . json ( { } ) ;
6868 const { status, data } = JSON . parse ( redisData ) ;
6969 c . status = status ;
0 commit comments