File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -46,17 +46,39 @@ HASHES_ROUTER.get("/:version", async (c) => {
4646 } ) ;
4747} ) ;
4848
49+ HASHES_ROUTER . get ( "/:version/:item" , async ( c ) => {
50+ const version = c . req . param ( "version" ) ;
51+ const item = c . req . param ( "item" ) ;
52+
53+ const hash = await c . env . MOJIS_HASHES . get ( `${ getKVPrefix ( c . env . ENVIRONMENT ) } :${ version } :${ item } ` ) ;
54+
55+ if ( hash == null ) {
56+ throw new HTTPException ( 404 , {
57+ message : "Hash not found" ,
58+ } ) ;
59+ }
60+
61+ return c . json ( {
62+ hash,
63+ } ) ;
64+ } ) ;
65+
4966HASHES_ROUTER . post (
50- "/:version " ,
67+ "/" ,
5168 authMiddleware ,
5269 arktypeValidator ( "json" , type ( {
53- hash : type ( "string" ) ,
70+ version : "string" ,
71+ item : "string?" ,
72+ hash : "string" ,
5473 } ) ) ,
5574 async ( c ) => {
56- const version = c . req . param ( "version" ) ;
57- const { hash } = c . req . valid ( "json" ) ;
75+ const { version, item, hash } = c . req . valid ( "json" ) ;
5876
59- await c . env . MOJIS_HASHES . put ( `${ getKVPrefix ( c . env . ENVIRONMENT ) } :${ version } ` , hash ) ;
77+ if ( item != null ) {
78+ await c . env . MOJIS_HASHES . put ( `${ getKVPrefix ( c . env . ENVIRONMENT ) } :${ version } :${ item } ` , hash ) ;
79+ } else {
80+ await c . env . MOJIS_HASHES . put ( `${ getKVPrefix ( c . env . ENVIRONMENT ) } :${ version } ` , hash ) ;
81+ }
6082
6183 return c . json ( {
6284 hash,
You can’t perform that action at this time.
0 commit comments