mirror of
https://github.com/wu736139669/hapi.git
synced 2026-08-05 06:24:37 +00:00
fix: add type safety improvements and fix Bun runtime type issues
- Replace embeddedAssets stub with generated type definitions - Fix Bun.isCompiled access with proper type assertion to prevent undefined errors - Improve router search validation with explicit SessionFileSearch type - Simplify middleware return patterns for better readability
This commit is contained in:
@@ -95,13 +95,11 @@ function createWebApp(options: {
|
||||
|
||||
app.use('*', async (c, next) => {
|
||||
if (c.req.path.startsWith('/api')) {
|
||||
await next()
|
||||
return
|
||||
return await next()
|
||||
}
|
||||
|
||||
if (c.req.method !== 'GET' && c.req.method !== 'HEAD') {
|
||||
await next()
|
||||
return
|
||||
return await next()
|
||||
}
|
||||
|
||||
const asset = embeddedAssetMap.get(c.req.path)
|
||||
@@ -109,7 +107,7 @@ function createWebApp(options: {
|
||||
return serveEmbeddedAsset(asset)
|
||||
}
|
||||
|
||||
await next()
|
||||
return await next()
|
||||
})
|
||||
|
||||
app.get('*', async (c, next) => {
|
||||
@@ -165,7 +163,8 @@ export async function startWebServer(options: {
|
||||
jwtSecret: Uint8Array
|
||||
socketEngine: SocketEngine
|
||||
}): Promise<BunServer<WebSocketData>> {
|
||||
const embeddedAssetMap = Bun.isCompiled ? await loadEmbeddedAssetMap() : null
|
||||
const bunRuntime = (globalThis as typeof globalThis & { Bun?: { isCompiled?: boolean } }).Bun
|
||||
const embeddedAssetMap = bunRuntime?.isCompiled ? await loadEmbeddedAssetMap() : null
|
||||
const app = createWebApp({
|
||||
getSyncEngine: options.getSyncEngine,
|
||||
getSseManager: options.getSseManager,
|
||||
|
||||
Reference in New Issue
Block a user