@@ -13,6 +13,7 @@ import kv from './routes/kv';
1313import storage from './routes/storage' ;
1414import ai from './routes/ai' ;
1515import pkg from '../package.json' ;
16+ import { sql } from './services/db/client' ;
1617
1718export const app = new Hono ( ) ;
1819
@@ -24,11 +25,24 @@ if (nodeEnv === 'development') {
2425 app . use ( '*' , cors ( ) ) ;
2526}
2627
28+ // API routes (no version prefix for health checks)
29+ const api = new Hono ( ) ;
30+
2731// Health check (no auth required)
28- app . get ( '/health' , ( c ) => {
32+ api . get ( '/health' , ( c ) => {
2933 return c . json ( { status : 'ok' , timestamp : new Date ( ) . toISOString ( ) } ) ;
3034} ) ;
3135
36+ // Postgate connection test (no auth required)
37+ api . get ( '/postgate' , async ( c ) => {
38+ try {
39+ const result = await sql < { result : number } > ( 'SELECT 1 + 1 AS result' ) ;
40+ return c . json ( { status : 'ok' , result : result [ 0 ] ?. result } ) ;
41+ } catch ( error ) {
42+ return c . json ( { status : 'error' , error : String ( error ) } , 500 ) ;
43+ }
44+ } ) ;
45+
3246// API v1 routes
3347const v1 = new Hono ( ) ;
3448
@@ -55,7 +69,8 @@ v1.route('/storage', storage);
5569v1 . route ( '/ai' , ai ) ;
5670v1 . route ( '/' , users ) ;
5771
58- app . route ( '/api/v1' , v1 ) ;
72+ api . route ( '/v1' , v1 ) ;
73+ app . route ( '/api' , api ) ;
5974
6075import { nodeEnv , port } from './config' ;
6176
0 commit comments