[ci] format
This commit is contained in:
parent
0cc6ede362
commit
c17efc1ad9
4 changed files with 25 additions and 11 deletions
|
@ -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') {
|
||||
|
|
|
@ -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 =
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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 () => {
|
||||
|
|
Loading…
Reference in a new issue