11import { Hono } from 'hono' ;
22import { cors } from 'hono/cors' ;
33import { logger } from 'hono/logger' ;
4+
45import { nodeEnv , port } from './config' ;
56import { createAuthMiddleware , extractUser , errorHandler } from './middlewares/auth' ;
67import authRoutes from './routes/auth' ;
@@ -15,9 +16,8 @@ import kv from './routes/kv';
1516import storage from './routes/storage' ;
1617import ai from './routes/ai' ;
1718import apiKeys from './routes/api-keys' ;
19+ import health from './routes/health' ;
1820import pkg from '../package.json' ;
19- import { sql } from './services/db/client' ;
20- import { WasmCron } from '@openworkers/croner-wasm' ;
2121
2222export const app = new Hono ( ) ;
2323
@@ -32,38 +32,8 @@ if (nodeEnv === 'development') {
3232// API routes (no version prefix for health checks)
3333const api = new Hono ( ) ;
3434
35- // Health check (no auth required)
36- api . get ( '/health' , ( c ) => {
37- return c . json ( { status : 'ok' , timestamp : new Date ( ) . toISOString ( ) } ) ;
38- } ) ;
39-
40- // Postgate connection test (no auth required)
41- api . get ( '/postgate' , async ( c ) => {
42- try {
43- const result = await sql < { result : number } > ( 'SELECT 1 + 1 AS result' ) ;
44- return c . json ( { status : 'ok' , result : result [ 0 ] ?. result } ) ;
45- } catch ( error ) {
46- return c . json ( { status : 'error' , error : String ( error ) } , 500 ) ;
47- }
48- } ) ;
49-
50- // Cron WASM test (no auth required)
51- api . get ( '/cron-test' , ( c ) => {
52- const pattern = c . req . query ( 'pattern' ) || '*/5 * * * *' ;
53- try {
54- const cron = new WasmCron ( pattern ) ;
55- return c . json ( {
56- status : 'ok' ,
57- wasm : true ,
58- pattern : cron . pattern ( ) ,
59- description : cron . describe ( ) ,
60- nextRun : cron . nextRun ( ) ?. toISOString ( ) ?? null ,
61- nextRuns : cron . nextRuns ( 5 ) . map ( ( d : Date ) => d . toISOString ( ) )
62- } ) ;
63- } catch ( error ) {
64- return c . json ( { status : 'error' , wasm : true , error : String ( error ) } , 400 ) ;
65- }
66- } ) ;
35+ // Health endpoints (no auth required)
36+ api . route ( '/health' , health ) ;
6737
6838// API v1 routes
6939const v1 = new Hono ( ) ;
0 commit comments