From 8a721173b3044f978173d97d608891f792dd2d71 Mon Sep 17 00:00:00 2001 From: matthewp Date: Fri, 24 Mar 2023 15:32:44 +0000 Subject: [PATCH] [ci] format --- packages/astro/src/core/app/node.ts | 30 +++++++++++++++-------------- 1 file changed, 16 insertions(+), 14 deletions(-) diff --git a/packages/astro/src/core/app/node.ts b/packages/astro/src/core/app/node.ts index 8561c459c3..9204ed78e5 100644 --- a/packages/astro/src/core/app/node.ts +++ b/packages/astro/src/core/app/node.ts @@ -31,7 +31,7 @@ function createRequestFromNodeRequest(req: NodeIncomingMessage, body?: Uint8Arra class NodeIncomingMessage extends IncomingMessage { /** - * The read-only body property of the Request interface contains a ReadableStream with the body contents that have been added to the request. + * The read-only body property of the Request interface contains a ReadableStream with the body contents that have been added to the request. */ body?: any | undefined; } @@ -41,19 +41,21 @@ export class NodeApp extends App { return super.match(req instanceof Request ? req : createRequestFromNodeRequest(req), opts); } render(req: NodeIncomingMessage | Request, routeData?: RouteData) { - if (typeof (req.body) === 'string' && req.body.length > 0) { - return super.render( + if (typeof req.body === 'string' && req.body.length > 0) { + return super.render( req instanceof Request ? req : createRequestFromNodeRequest(req, Buffer.from(req.body)), - routeData - ); - } - - if ((typeof (req.body) === 'object') && (Object.keys(req.body).length > 0)) { - return super.render( - req instanceof Request ? req : createRequestFromNodeRequest(req, Buffer.from(JSON.stringify(req.body))), - routeData - ); - } + routeData + ); + } + + if (typeof req.body === 'object' && Object.keys(req.body).length > 0) { + return super.render( + req instanceof Request + ? req + : createRequestFromNodeRequest(req, Buffer.from(JSON.stringify(req.body))), + routeData + ); + } if ('on' in req) { let body = Buffer.from([]); @@ -93,4 +95,4 @@ export async function loadManifest(rootFolder: URL): Promise { export async function loadApp(rootFolder: URL): Promise { const manifest = await loadManifest(rootFolder); return new NodeApp(manifest); -} \ No newline at end of file +}