[ci] format
This commit is contained in:
parent
1048aca550
commit
57e9a28063
1 changed files with 8 additions and 4 deletions
|
@ -96,7 +96,11 @@ export let ResponseWithEncoding: ReturnType<typeof initResponseWithEncoding>;
|
||||||
// TODO Remove this after StackBlitz supports Node 18.
|
// TODO Remove this after StackBlitz supports Node 18.
|
||||||
let initResponseWithEncoding = () => {
|
let initResponseWithEncoding = () => {
|
||||||
class LocalResponseWithEncoding extends Response {
|
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.
|
// 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.
|
// We don't do the full handling as simple objects so users can control how headers are set instead.
|
||||||
if (typeof body === 'string') {
|
if (typeof body === 'string') {
|
||||||
|
@ -109,9 +113,9 @@ let initResponseWithEncoding = () => {
|
||||||
body = encoder.encode(body);
|
body = encoder.encode(body);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
super(body, init);
|
super(body, init);
|
||||||
|
|
||||||
if (encoding) {
|
if (encoding) {
|
||||||
this.headers.set('X-Astro-Encoding', encoding);
|
this.headers.set('X-Astro-Encoding', encoding);
|
||||||
}
|
}
|
||||||
|
@ -125,7 +129,7 @@ let initResponseWithEncoding = () => {
|
||||||
initResponseWithEncoding = (() => {}) as any;
|
initResponseWithEncoding = (() => {}) as any;
|
||||||
|
|
||||||
return LocalResponseWithEncoding;
|
return LocalResponseWithEncoding;
|
||||||
}
|
};
|
||||||
|
|
||||||
export async function callEndpoint<MiddlewareResult = Response | EndpointOutput>(
|
export async function callEndpoint<MiddlewareResult = Response | EndpointOutput>(
|
||||||
mod: EndpointHandler,
|
mod: EndpointHandler,
|
||||||
|
|
Loading…
Reference in a new issue