[ci] format

This commit is contained in:
matthewp 2022-07-22 20:32:12 +00:00 committed by fredkbot
parent 0cc6ede362
commit c17efc1ad9
4 changed files with 25 additions and 11 deletions

View file

@ -58,9 +58,9 @@ export class App {
}
let routeData = matchRoute(url.pathname, this.#manifestData);
if(routeData) {
if (routeData) {
return routeData;
} else if(matchNotFound) {
} else if (matchNotFound) {
return matchRoute('/404', this.#manifestData);
} else {
return undefined;
@ -88,12 +88,17 @@ export class App {
let response = await this.#renderPage(request, routeData, mod, defaultStatus);
// If there was a 500 error, try sending the 500 page.
if(response.status === 500) {
if (response.status === 500) {
const fiveHundredRouteData = matchRoute('/500', this.#manifestData);
if(fiveHundredRouteData) {
if (fiveHundredRouteData) {
mod = this.#manifest.pageMap.get(fiveHundredRouteData.component)!;
try {
let fiveHundredResponse = await this.#renderPage(request, fiveHundredRouteData, mod, 500);
let fiveHundredResponse = await this.#renderPage(
request,
fiveHundredRouteData,
mod,
500
);
return fiveHundredResponse;
} catch {}
}
@ -159,7 +164,7 @@ export class App {
ssr: true,
request,
streaming: this.#streaming,
status
status,
});
return response;
@ -188,7 +193,7 @@ export class App {
route: routeData,
routeCache: this.#routeCache,
ssr: true,
status
status,
});
if (result.type === 'response') {

View file

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

View file

@ -108,7 +108,7 @@ export async function render(opts: RenderOptions): Promise<Response> {
site,
ssr,
streaming,
status = 200
status = 200,
} = opts;
const paramsAndPropsRes = await getParamsAndProps({
@ -150,7 +150,7 @@ export async function render(opts: RenderOptions): Promise<Response> {
scripts,
ssr,
streaming,
status
status,
});
// Support `export const components` for `MDX` pages

View file

@ -15,7 +15,7 @@ describe('404 and 500 pages', () => {
},
adapter: testAdapter(),
});
await fixture.build({ });
await fixture.build({});
});
it('404 page returned when a route does not match', async () => {