Skip to content
Myr

refactor(hono-base): remove `any` casting (#1535)

Before adoption: this commit came in with the history the project adopted, so no landing records it.

* refactor(hono-base): remove `any` casting * denoify

authored by Yusuke Wada · committed by GitHub · parent e326208 · Browse files · 2 files+12 added−24 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

2 files+12 added−24 removed

  • other:+12 added−24 removed

2 files+12 added−24 removed

modified:deno_dist/hono-base.ts+6 added-12 removed
88 unmodified lines
89 if (typeof handler !== 'string') {90 this.addRoute(method, this.path, handler)91 }92 })93 // eslint-disable-next-line @typescript-eslint/no-explicit-any94 return this as any93 return this94 }95 })9697 // Implementation of app.on(method, path, ...handlers[])
4 unmodified lines
102 handlers.map((handler) => {103 this.addRoute(m.toUpperCase(), this.path, handler)104 })105 }107 // eslint-disable-next-line @typescript-eslint/no-explicit-any108 return this as any106 return this107 }108109 // Implementation of app.use(...handlers[]) or app.get(path, ...handlers[])110 // eslint-disable-next-line @typescript-eslint/no-explicit-any
53 unmodified lines
164 ): Hono<E, MergeSchemaPath<SubSchema, MergePath<BasePath, SubPath>> & S, BasePath> {165 const subApp = this.basePath(path)166167 if (!app) {170 // eslint-disable-next-line @typescript-eslint/no-explicit-any171 return subApp as any168 return subApp169 }170171 app.routes.map((r) => {172 const handler =
2 unmodified lines
175 : async (c: Context, next: Next) =>176 (await compose<Context>([r.handler], app.errorHandler)(c, next)).res177 subApp.addRoute(r.method, r.path, handler)178 })182 // eslint-disable-next-line @typescript-eslint/no-explicit-any183 return this as any179 return this180 }181182 basePath<SubPath extends string>(path: SubPath): Hono<E, S, MergePath<BasePath, SubPath>> {183 const subApp = this.clone()184 subApp._basePath = mergePath(this._basePath, path)189 // eslint-disable-next-line @typescript-eslint/no-explicit-any190 return subApp as any185 return subApp186 }187188 onError(handler: ErrorHandler<E>) {189 this.errorHandler = handler
94 unmodified lines
284 executionCtx: ExecutionContext | FetchEventLike | undefined,285 env: E['Bindings'],286 method: string287 ): Response | Promise<Response> {293 const path = this.getPath(request, { env })294288 // Handle HEAD method289 if (method === 'HEAD') {290 return (async () =>291 new Response(null, await this.dispatch(request, executionCtx, env, 'GET')))()292 }293294 const path = this.getPath(request, { env })295 const { handlers, params } = this.matchRoute(method, path)296297 const c = new Context(new HonoRequest(request, path, params), {298 env,
101 unmodified lines
modified:src/hono-base.ts+6 added-12 removed
88 unmodified lines
89 if (typeof handler !== 'string') {90 this.addRoute(method, this.path, handler)91 }92 })93 // eslint-disable-next-line @typescript-eslint/no-explicit-any94 return this as any93 return this94 }95 })9697 // Implementation of app.on(method, path, ...handlers[])
4 unmodified lines
102 handlers.map((handler) => {103 this.addRoute(m.toUpperCase(), this.path, handler)104 })105 }107 // eslint-disable-next-line @typescript-eslint/no-explicit-any108 return this as any106 return this107 }108109 // Implementation of app.use(...handlers[]) or app.get(path, ...handlers[])110 // eslint-disable-next-line @typescript-eslint/no-explicit-any
53 unmodified lines
164 ): Hono<E, MergeSchemaPath<SubSchema, MergePath<BasePath, SubPath>> & S, BasePath> {165 const subApp = this.basePath(path)166167 if (!app) {170 // eslint-disable-next-line @typescript-eslint/no-explicit-any171 return subApp as any168 return subApp169 }170171 app.routes.map((r) => {172 const handler =
2 unmodified lines
175 : async (c: Context, next: Next) =>176 (await compose<Context>([r.handler], app.errorHandler)(c, next)).res177 subApp.addRoute(r.method, r.path, handler)178 })182 // eslint-disable-next-line @typescript-eslint/no-explicit-any183 return this as any179 return this180 }181182 basePath<SubPath extends string>(path: SubPath): Hono<E, S, MergePath<BasePath, SubPath>> {183 const subApp = this.clone()184 subApp._basePath = mergePath(this._basePath, path)189 // eslint-disable-next-line @typescript-eslint/no-explicit-any190 return subApp as any185 return subApp186 }187188 onError(handler: ErrorHandler<E>) {189 this.errorHandler = handler
94 unmodified lines
284 executionCtx: ExecutionContext | FetchEventLike | undefined,285 env: E['Bindings'],286 method: string287 ): Response | Promise<Response> {293 const path = this.getPath(request, { env })294288 // Handle HEAD method289 if (method === 'HEAD') {290 return (async () =>291 new Response(null, await this.dispatch(request, executionCtx, env, 'GET')))()292 }293294 const path = this.getPath(request, { env })295 const { handlers, params } = this.matchRoute(method, path)296297 const c = new Context(new HonoRequest(request, path, params), {298 env,
101 unmodified lines