[ci] format

This commit is contained in:
matthewp 2022-03-29 11:36:02 +00:00 committed by GitHub Actions
parent ecc6a4833f
commit f0275298bd
3 changed files with 11 additions and 18 deletions

View file

@ -3,8 +3,7 @@ import type { RenderOptions } from '../render/core';
import { renderEndpoint } from '../../runtime/server/index.js';
import { getParamsAndProps, GetParamsAndPropsError } from '../render/core.js';
export type EndpointOptions = Pick<RenderOptions, 'logging' | 'origin' |
'request' | 'route' | 'routeCache' | 'pathname' | 'route' | 'site' | 'ssr'>;
export type EndpointOptions = Pick<RenderOptions, 'logging' | 'origin' | 'request' | 'route' | 'routeCache' | 'pathname' | 'route' | 'site' | 'ssr'>;
type EndpointCallResult =
| {

View file

@ -11,18 +11,12 @@ export interface CreateRequestOptions {
logging: LogOptions;
}
export function createRequest({
url,
headers,
method = 'GET',
logging
}: CreateRequestOptions): Request {
let headersObj = headers instanceof Headers ? headers :
new Headers(Object.entries(headers as Record<string, any>));
export function createRequest({ url, headers, method = 'GET', logging }: CreateRequestOptions): Request {
let headersObj = headers instanceof Headers ? headers : new Headers(Object.entries(headers as Record<string, any>));
const request = new Request(url.toString(), {
method: method,
headers: headersObj
headers: headersObj,
});
Object.defineProperties(request, {
@ -30,14 +24,14 @@ export function createRequest({
get() {
warn(logging, 'deprecation', `Astro.request.canonicalURL has been moved to Astro.canonicalURL`);
return undefined;
}
},
},
params: {
get() {
warn(logging, 'deprecation', `Astro.request.params has been moved to Astro.params`);
return undefined;
}
}
},
},
});
return request;

View file

@ -121,9 +121,9 @@ async function handleRequest(
const url = new URL(origin + req.url);
const pathname = decodeURI(url.pathname);
const rootRelativeUrl = pathname.substring(devRoot.length - 1);
if(!buildingToSSR) {
if (!buildingToSSR) {
// Prevent user from depending on search params when not doing SSR.
for(const [key] of url.searchParams) {
for (const [key] of url.searchParams) {
url.searchParams.delete(key);
}
}
@ -133,7 +133,7 @@ async function handleRequest(
url,
headers: buildingToSSR ? req.headers : new Headers(),
method: req.method,
logging
logging,
});
try {