mirror of
https://github.com/withastro/astro.git
synced 2024-12-23 21:53:55 -05:00
[ci] format
This commit is contained in:
parent
b7194103e3
commit
8a721173b3
1 changed files with 16 additions and 14 deletions
|
@ -31,7 +31,7 @@ function createRequestFromNodeRequest(req: NodeIncomingMessage, body?: Uint8Arra
|
||||||
|
|
||||||
class NodeIncomingMessage extends IncomingMessage {
|
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;
|
body?: any | undefined;
|
||||||
}
|
}
|
||||||
|
@ -41,19 +41,21 @@ export class NodeApp extends App {
|
||||||
return super.match(req instanceof Request ? req : createRequestFromNodeRequest(req), opts);
|
return super.match(req instanceof Request ? req : createRequestFromNodeRequest(req), opts);
|
||||||
}
|
}
|
||||||
render(req: NodeIncomingMessage | Request, routeData?: RouteData) {
|
render(req: NodeIncomingMessage | Request, routeData?: RouteData) {
|
||||||
if (typeof (req.body) === 'string' && req.body.length > 0) {
|
if (typeof req.body === 'string' && req.body.length > 0) {
|
||||||
return super.render(
|
return super.render(
|
||||||
req instanceof Request ? req : createRequestFromNodeRequest(req, Buffer.from(req.body)),
|
req instanceof Request ? req : createRequestFromNodeRequest(req, Buffer.from(req.body)),
|
||||||
routeData
|
routeData
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((typeof (req.body) === 'object') && (Object.keys(req.body).length > 0)) {
|
if (typeof req.body === 'object' && Object.keys(req.body).length > 0) {
|
||||||
return super.render(
|
return super.render(
|
||||||
req instanceof Request ? req : createRequestFromNodeRequest(req, Buffer.from(JSON.stringify(req.body))),
|
req instanceof Request
|
||||||
routeData
|
? req
|
||||||
);
|
: createRequestFromNodeRequest(req, Buffer.from(JSON.stringify(req.body))),
|
||||||
}
|
routeData
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
if ('on' in req) {
|
if ('on' in req) {
|
||||||
let body = Buffer.from([]);
|
let body = Buffer.from([]);
|
||||||
|
@ -93,4 +95,4 @@ export async function loadManifest(rootFolder: URL): Promise<SSRManifest> {
|
||||||
export async function loadApp(rootFolder: URL): Promise<NodeApp> {
|
export async function loadApp(rootFolder: URL): Promise<NodeApp> {
|
||||||
const manifest = await loadManifest(rootFolder);
|
const manifest = await loadManifest(rootFolder);
|
||||||
return new NodeApp(manifest);
|
return new NodeApp(manifest);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue