Skip to content

Commit

Permalink
[ci] format
Browse files Browse the repository at this point in the history
  • Loading branch information
matthewp authored and astrobot-houston committed Mar 24, 2023
1 parent b719410 commit 8a72117
Showing 1 changed file with 16 additions and 14 deletions.
30 changes: 16 additions & 14 deletions packages/astro/src/core/app/node.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand All @@ -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([]);
Expand Down Expand Up @@ -93,4 +95,4 @@ export async function loadManifest(rootFolder: URL): Promise<SSRManifest> {
export async function loadApp(rootFolder: URL): Promise<NodeApp> {
const manifest = await loadManifest(rootFolder);
return new NodeApp(manifest);
}
}

0 comments on commit 8a72117

Please sign in to comment.