Skip to content

Commit b18d4bf

Browse files
bluwyastrobot-houston
authored andcommitted
[ci] format
1 parent 21e0757 commit b18d4bf

File tree

3 files changed

+19
-23
lines changed

3 files changed

+19
-23
lines changed

packages/astro/src/core/endpoint/index.ts

+17-21
Original file line numberDiff line numberDiff line change
@@ -91,32 +91,28 @@ export function createAPIContext({
9191

9292
type ResponseParameters = ConstructorParameters<typeof Response>;
9393

94-
export class ResponseWithEncoding extends Response {
95-
constructor(
96-
body: ResponseParameters[0],
97-
init: ResponseParameters[1],
98-
encoding?: BufferEncoding
99-
) {
100-
// If a body string is given, try to encode it to preserve the behaviour as simple objects.
101-
// We don't do the full handling as simple objects so users can control how headers are set instead.
102-
if (typeof body === 'string') {
103-
// In NodeJS, we can use Buffer.from which supports all BufferEncoding
104-
if (typeof Buffer !== 'undefined' && Buffer.from) {
105-
body = Buffer.from(body, encoding);
106-
}
107-
// In non-NodeJS, use the web-standard TextEncoder for utf-8 strings
108-
else if (encoding == null || encoding === 'utf8' || encoding === 'utf-8') {
109-
body = encoder.encode(body);
110-
}
94+
export class ResponseWithEncoding extends Response {
95+
constructor(body: ResponseParameters[0], init: ResponseParameters[1], encoding?: BufferEncoding) {
96+
// If a body string is given, try to encode it to preserve the behaviour as simple objects.
97+
// We don't do the full handling as simple objects so users can control how headers are set instead.
98+
if (typeof body === 'string') {
99+
// In NodeJS, we can use Buffer.from which supports all BufferEncoding
100+
if (typeof Buffer !== 'undefined' && Buffer.from) {
101+
body = Buffer.from(body, encoding);
102+
}
103+
// In non-NodeJS, use the web-standard TextEncoder for utf-8 strings
104+
else if (encoding == null || encoding === 'utf8' || encoding === 'utf-8') {
105+
body = encoder.encode(body);
111106
}
107+
}
112108

113-
super(body, init);
109+
super(body, init);
114110

115-
if (encoding) {
116-
this.headers.set('X-Astro-Encoding', encoding);
117-
}
111+
if (encoding) {
112+
this.headers.set('X-Astro-Encoding', encoding);
118113
}
119114
}
115+
}
120116

121117
export async function callEndpoint<MiddlewareResult = Response | EndpointOutput>(
122118
mod: EndpointHandler,

packages/astro/src/core/polyfill.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import crypto from 'node:crypto';
21
import buffer from 'node:buffer';
2+
import crypto from 'node:crypto';
33

44
export function apply() {
55
// Remove when Node 18 is dropped for Node 20

packages/integrations/node/src/createOutgoingHttpHeaders.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ export const createOutgoingHttpHeaders = (
1313
if (!headers) {
1414
return undefined;
1515
}
16-
16+
1717
// 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)
1818
const nodeHeaders: OutgoingHttpHeaders = Object.fromEntries(headers.entries());
1919

0 commit comments

Comments
 (0)