mirror of
https://github.com/honojs/hono.git
synced 2024-12-01 11:51:01 +01:00
refactor: shorten
This commit is contained in:
parent
b1973d0c7f
commit
c6b434addd
@ -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
|
||||
|
@ -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) {
|
||||
|
@ -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
|
||||
|
@ -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) {
|
||||
|
Loading…
Reference in New Issue
Block a user