Skip to content
Myr

fix(validator): `await` cached contents (#2430)

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

* fix(validator): `await` cached contents * denoify

authored by Yusuke Wada · committed by GitHub · parent f590d0f · Browse files · 3 files+10 added−4 removed
This commit

State

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

Diff stats

3 files+10 added−4 removed

  • tests:+6 added−0 removed
  • other:+4 added−4 removed

3 files+10 added−4 removed

modified:deno_dist/validator/validator.ts+2 added-2 removed
modified:src/validator/validator.test.ts+6 added
184 unmodified lines
185 await c.req[type]()186 await next()187 },188 validator('json', (value) => {189 if (value instanceof Promise) {190 throw new Error('Value is Promise')191 }192 return value193 }),194 async (c) => {195 const data = await c.req.json()
30 unmodified lines
226 await c.req[type]()227 await next()228 },229 validator('form', (value) => {230 if (value instanceof Promise) {231 throw new Error('Value is Promise')232 }233 return value234 }),235 async (c) => {236 return c.json({ message: 'OK' }, 200)
718 unmodified lines
modified:src/validator/validator.ts+2 added-2 removed
68 unmodified lines
69 throw new HTTPException(400, { message })70 }7172 if (c.req.bodyCache.json) {73 value = c.req.bodyCache.json73 value = await c.req.bodyCache.json74 break75 }7677 try {
20 unmodified lines
98 break99 }100101 if (c.req.bodyCache.formData) {102 value = c.req.bodyCache.formData102 value = await c.req.bodyCache.formData103 break104 }105106 try {
54 unmodified lines