diff --git a/handlers/static.ts b/handlers/static.ts index f6865963..51c73095 100644 --- a/handlers/static.ts +++ b/handlers/static.ts @@ -14,7 +14,7 @@ export interface staticHandlerOptions extends HandlerOptions { * Optionally: provide custom headers and/or body transform fcn. * * @param fileURL: URL object of file address - * @param opts: (optional) HandlerOptions + * @param opts: (optional) staticHandlerOptions * @returns Handler: (ctx: RequestContext) => Promise */ export const staticHandler = (fileURL: URL, opts: staticHandlerOptions = {}): Handler => async (_ctx: RequestContext) => { diff --git a/server.ts b/server.ts index df0319b8..31c9e96c 100644 --- a/server.ts +++ b/server.ts @@ -60,14 +60,19 @@ export class Server extends Router { * Start listening to HTTP requests. * @param port: number * @param onListen: onListen callback function - * @param onError: onListen callback function + * @param onError: error handler */ - async listen(port?: number, onListen?: (server: stdServer) => void): Promise { + async listen( + port?: number, + onListen?: (server: stdServer) => void, + onError?: (error: unknown) => Response | Promise + ): Promise { if (port) this.port = port this.stdServer = new stdServer({ port: this.port, - handler: (request: Request) => this.requestHandler.call(this, request) + handler: (request: Request) => this.requestHandler.call(this, request), + onError }) if (onListen) {