Skip to content

Commit

Permalink
perf: remove readBody Nitro workaround
Browse files Browse the repository at this point in the history
  • Loading branch information
johannschopplich committed May 23, 2023
1 parent d8f7d72 commit a403eda
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 11 deletions.
5 changes: 1 addition & 4 deletions .eslintrc
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
{
"extends": "@antfu",
"rules": {
"n/prefer-global/buffer": "off"
}
"extends": "@antfu"
}
8 changes: 1 addition & 7 deletions src/runtime/server.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { createError, defineEventHandler, getRequestHeader, getRouterParam, readBody } from 'h3'
import destr from 'destr'
import type { FetchError } from 'ofetch'
import type { ModuleOptions } from '../module'
import { deserializeMaybeEncodedBody } from './utils'
Expand All @@ -19,12 +18,7 @@ export default defineEventHandler(async (event): Promise<any> => {
})
}

let _body = await readBody<EndpointFetchOptions>(event)

// Inconsistent `readBody` behavior in some Nitro presets
// https://github.com/unjs/nitro/issues/912
if (Buffer.isBuffer(_body))
_body = destr((_body as Buffer).toString())
const _body = await readBody<EndpointFetchOptions>(event)

const {
path,
Expand Down

0 comments on commit a403eda

Please sign in to comment.