0
0
mirror of https://github.com/honojs/hono.git synced 2024-12-01 11:51:01 +01:00

refactor: shorten

This commit is contained in:
Yusuke Wada 2022-12-13 20:36:30 +09:00
parent b1973d0c7f
commit c6b434addd
4 changed files with 6 additions and 6 deletions

View File

@ -37,7 +37,7 @@ export class Context<
notFoundHandler: NotFoundHandler<E> = () => new Response()
) {
this._executionCtx = executionCtx
this.req = req as Request<unknown, P, S extends Schema ? SchemaToProp<S> : S>
this.req = req as Request<unknown, P>
this.env = env
this.notFoundHandler = notFoundHandler

View File

@ -40,14 +40,14 @@ export const validatorMiddleware = <
}
const schema = validationFunction(v, c)
const validatorList = getValidatorList<S>(schema)
const validatorList = getValidatorList(schema)
// eslint-disable-next-line @typescript-eslint/no-explicit-any
let data: any = {}
for (const [keys, validator] of validatorList) {
let results: ValidateResult[]
try {
results = await validator.validate(c.req as Request)
results = await validator.validate(c.req)
} catch (e) {
// Invalid JSON request
if (e instanceof Error) {

View File

@ -37,7 +37,7 @@ export class Context<
notFoundHandler: NotFoundHandler<E> = () => new Response()
) {
this._executionCtx = executionCtx
this.req = req as Request<unknown, P, S extends Schema ? SchemaToProp<S> : S>
this.req = req as Request<unknown, P>
this.env = env
this.notFoundHandler = notFoundHandler

View File

@ -40,14 +40,14 @@ export const validatorMiddleware = <
}
const schema = validationFunction(v, c)
const validatorList = getValidatorList<S>(schema)
const validatorList = getValidatorList(schema)
// eslint-disable-next-line @typescript-eslint/no-explicit-any
let data: any = {}
for (const [keys, validator] of validatorList) {
let results: ValidateResult[]
try {
results = await validator.validate(c.req as Request)
results = await validator.validate(c.req)
} catch (e) {
// Invalid JSON request
if (e instanceof Error) {