summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar bluwy <bluwy@users.noreply.github.com> 2023-10-04 10:31:04 +0000
committerGravatar astrobot-houston <fred+astrobot@astro.build> 2023-10-04 10:31:04 +0000
commitb18d4bf3b17cf98cf5bbc488772773bdfcc38ec4 (patch)
treeb5e9ab2e32839c79cead00bcf2ddc4f7ced9f16e
parent21e0757ea22a57d344c934045ca19db93b684436 (diff)
downloadastro-b18d4bf3b17cf98cf5bbc488772773bdfcc38ec4.tar.gz
astro-b18d4bf3b17cf98cf5bbc488772773bdfcc38ec4.tar.zst
astro-b18d4bf3b17cf98cf5bbc488772773bdfcc38ec4.zip
[ci] format
-rw-r--r--packages/astro/src/core/endpoint/index.ts38
-rw-r--r--packages/astro/src/core/polyfill.ts2
-rw-r--r--packages/integrations/node/src/createOutgoingHttpHeaders.ts2
3 files changed, 19 insertions, 23 deletions
diff --git a/packages/astro/src/core/endpoint/index.ts b/packages/astro/src/core/endpoint/index.ts
index 9720fea66..b62ba8bed 100644
--- a/packages/astro/src/core/endpoint/index.ts
+++ b/packages/astro/src/core/endpoint/index.ts
@@ -91,32 +91,28 @@ export function createAPIContext({
type ResponseParameters = ConstructorParameters<typeof Response>;
- export class ResponseWithEncoding extends Response {
- constructor(
- body: ResponseParameters[0],
- init: ResponseParameters[1],
- encoding?: BufferEncoding
- ) {
- // If a body string is given, try to encode it to preserve the behaviour as simple objects.
- // We don't do the full handling as simple objects so users can control how headers are set instead.
- if (typeof body === 'string') {
- // In NodeJS, we can use Buffer.from which supports all BufferEncoding
- if (typeof Buffer !== 'undefined' && Buffer.from) {
- body = Buffer.from(body, encoding);
- }
- // In non-NodeJS, use the web-standard TextEncoder for utf-8 strings
- else if (encoding == null || encoding === 'utf8' || encoding === 'utf-8') {
- body = encoder.encode(body);
- }
+export class ResponseWithEncoding extends Response {
+ constructor(body: ResponseParameters[0], init: ResponseParameters[1], encoding?: BufferEncoding) {
+ // If a body string is given, try to encode it to preserve the behaviour as simple objects.
+ // We don't do the full handling as simple objects so users can control how headers are set instead.
+ if (typeof body === 'string') {
+ // In NodeJS, we can use Buffer.from which supports all BufferEncoding
+ if (typeof Buffer !== 'undefined' && Buffer.from) {
+ body = Buffer.from(body, encoding);
+ }
+ // In non-NodeJS, use the web-standard TextEncoder for utf-8 strings
+ else if (encoding == null || encoding === 'utf8' || encoding === 'utf-8') {
+ body = encoder.encode(body);
}
+ }
- super(body, init);
+ super(body, init);
- if (encoding) {
- this.headers.set('X-Astro-Encoding', encoding);
- }
+ if (encoding) {
+ this.headers.set('X-Astro-Encoding', encoding);
}
}
+}
export async function callEndpoint<MiddlewareResult = Response | EndpointOutput>(
mod: EndpointHandler,
diff --git a/packages/astro/src/core/polyfill.ts b/packages/astro/src/core/polyfill.ts
index 3b271d464..c183d23f6 100644
--- a/packages/astro/src/core/polyfill.ts
+++ b/packages/astro/src/core/polyfill.ts
@@ -1,5 +1,5 @@
-import crypto from 'node:crypto';
import buffer from 'node:buffer';
+import crypto from 'node:crypto';
export function apply() {
// Remove when Node 18 is dropped for Node 20
diff --git a/packages/integrations/node/src/createOutgoingHttpHeaders.ts b/packages/integrations/node/src/createOutgoingHttpHeaders.ts
index a2f9b74e8..781a74de6 100644
--- a/packages/integrations/node/src/createOutgoingHttpHeaders.ts
+++ b/packages/integrations/node/src/createOutgoingHttpHeaders.ts
@@ -13,7 +13,7 @@ export const createOutgoingHttpHeaders = (
if (!headers) {
return undefined;
}
-
+
// at this point, a multi-value'd set-cookie header is invalid (it was concatenated as a single CSV, which is not valid for set-cookie)
const nodeHeaders: OutgoingHttpHeaders = Object.fromEntries(headers.entries());