fix(server): 修复 strict 模式下类型错误
- errors.ts: status 转为 ContentfulStatusCode - server.ts: BunServer 泛型参数修正 - transcriptReader.ts: 补充 compactMetadata 类型声明
This commit is contained in:
parent
799ed96b37
commit
c96fe77c45
|
|
@ -1,4 +1,5 @@
|
|||
import type { Context } from 'hono'
|
||||
import type { ContentfulStatusCode } from 'hono/utils/http-status'
|
||||
import { HTTPException } from 'hono/http-exception'
|
||||
|
||||
export class ServeError extends Error {
|
||||
|
|
@ -42,18 +43,18 @@ export function sessionError(message: string): ServeError {
|
|||
|
||||
export function errorHandler(err: Error, c: Context) {
|
||||
if (err instanceof ServeError) {
|
||||
return c.json(err.json(), { status: err.status })
|
||||
return c.json(err.json(), { status: err.status as ContentfulStatusCode })
|
||||
}
|
||||
if (err instanceof HTTPException) {
|
||||
return c.json(
|
||||
{ error: 'HTTP_ERROR', message: err.message },
|
||||
{ status: err.status },
|
||||
{ status: err.status as ContentfulStatusCode },
|
||||
)
|
||||
}
|
||||
const message =
|
||||
err instanceof Error && err.stack ? err.stack : err.toString()
|
||||
return c.json(
|
||||
{ error: 'INTERNAL', message },
|
||||
{ status: 500 },
|
||||
{ status: 500 as ContentfulStatusCode },
|
||||
)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@ export function startServer(
|
|||
config: ServerConfig,
|
||||
sessionManager: SessionManager,
|
||||
eventBus: EventBus,
|
||||
): BunServer & { port?: number } {
|
||||
): BunServer<undefined> & { port?: number } {
|
||||
eventBus.startHeartbeat()
|
||||
|
||||
const app = new Hono()
|
||||
|
|
|
|||
|
|
@ -21,6 +21,10 @@ type TranscriptEntry = {
|
|||
content?: unknown
|
||||
}
|
||||
content?: unknown
|
||||
compactMetadata?: {
|
||||
preservedSegment?: unknown
|
||||
[key: string]: unknown
|
||||
}
|
||||
[key: string]: unknown
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user