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 Aug 28, 2023
1 parent 1048aca commit 57e9a28
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions packages/astro/src/core/endpoint/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,11 @@ export let ResponseWithEncoding: ReturnType<typeof initResponseWithEncoding>;
// TODO Remove this after StackBlitz supports Node 18.
let initResponseWithEncoding = () => {
class LocalResponseWithEncoding extends Response {
constructor(body: ResponseParameters[0], init: ResponseParameters[1], encoding?: BufferEncoding) {
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') {
Expand All @@ -109,9 +113,9 @@ let initResponseWithEncoding = () => {
body = encoder.encode(body);
}
}

super(body, init);

if (encoding) {
this.headers.set('X-Astro-Encoding', encoding);
}
Expand All @@ -125,7 +129,7 @@ let initResponseWithEncoding = () => {
initResponseWithEncoding = (() => {}) as any;

return LocalResponseWithEncoding;
}
};

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

0 comments on commit 57e9a28

Please sign in to comment.