[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);
|
let routeData = matchRoute(url.pathname, this.#manifestData);
|
||||||
|
|
||||||
if(routeData) {
|
if (routeData) {
|
||||||
return routeData;
|
return routeData;
|
||||||
} else if(matchNotFound) {
|
} else if (matchNotFound) {
|
||||||
return matchRoute('/404', this.#manifestData);
|
return matchRoute('/404', this.#manifestData);
|
||||||
} else {
|
} else {
|
||||||
return undefined;
|
return undefined;
|
||||||
|
@ -88,12 +88,17 @@ export class App {
|
||||||
let response = await this.#renderPage(request, routeData, mod, defaultStatus);
|
let response = await this.#renderPage(request, routeData, mod, defaultStatus);
|
||||||
|
|
||||||
// If there was a 500 error, try sending the 500 page.
|
// 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);
|
const fiveHundredRouteData = matchRoute('/500', this.#manifestData);
|
||||||
if(fiveHundredRouteData) {
|
if (fiveHundredRouteData) {
|
||||||
mod = this.#manifest.pageMap.get(fiveHundredRouteData.component)!;
|
mod = this.#manifest.pageMap.get(fiveHundredRouteData.component)!;
|
||||||
try {
|
try {
|
||||||
let fiveHundredResponse = await this.#renderPage(request, fiveHundredRouteData, mod, 500);
|
let fiveHundredResponse = await this.#renderPage(
|
||||||
|
request,
|
||||||
|
fiveHundredRouteData,
|
||||||
|
mod,
|
||||||
|
500
|
||||||
|
);
|
||||||
return fiveHundredResponse;
|
return fiveHundredResponse;
|
||||||
} catch {}
|
} catch {}
|
||||||
}
|
}
|
||||||
|
@ -159,7 +164,7 @@ export class App {
|
||||||
ssr: true,
|
ssr: true,
|
||||||
request,
|
request,
|
||||||
streaming: this.#streaming,
|
streaming: this.#streaming,
|
||||||
status
|
status,
|
||||||
});
|
});
|
||||||
|
|
||||||
return response;
|
return response;
|
||||||
|
@ -188,7 +193,7 @@ export class App {
|
||||||
route: routeData,
|
route: routeData,
|
||||||
routeCache: this.#routeCache,
|
routeCache: this.#routeCache,
|
||||||
ssr: true,
|
ssr: true,
|
||||||
status
|
status,
|
||||||
});
|
});
|
||||||
|
|
||||||
if (result.type === 'response') {
|
if (result.type === 'response') {
|
||||||
|
|
|
@ -5,7 +5,16 @@ import { getParamsAndProps, GetParamsAndPropsError } from '../render/core.js';
|
||||||
|
|
||||||
export type EndpointOptions = Pick<
|
export type EndpointOptions = Pick<
|
||||||
RenderOptions,
|
RenderOptions,
|
||||||
'logging' | 'origin' | 'request' | 'route' | 'routeCache' | 'pathname' | 'route' | 'site' | 'ssr' | 'status'
|
| 'logging'
|
||||||
|
| 'origin'
|
||||||
|
| 'request'
|
||||||
|
| 'route'
|
||||||
|
| 'routeCache'
|
||||||
|
| 'pathname'
|
||||||
|
| 'route'
|
||||||
|
| 'site'
|
||||||
|
| 'ssr'
|
||||||
|
| 'status'
|
||||||
>;
|
>;
|
||||||
|
|
||||||
type EndpointCallResult =
|
type EndpointCallResult =
|
||||||
|
|
|
@ -108,7 +108,7 @@ export async function render(opts: RenderOptions): Promise<Response> {
|
||||||
site,
|
site,
|
||||||
ssr,
|
ssr,
|
||||||
streaming,
|
streaming,
|
||||||
status = 200
|
status = 200,
|
||||||
} = opts;
|
} = opts;
|
||||||
|
|
||||||
const paramsAndPropsRes = await getParamsAndProps({
|
const paramsAndPropsRes = await getParamsAndProps({
|
||||||
|
@ -150,7 +150,7 @@ export async function render(opts: RenderOptions): Promise<Response> {
|
||||||
scripts,
|
scripts,
|
||||||
ssr,
|
ssr,
|
||||||
streaming,
|
streaming,
|
||||||
status
|
status,
|
||||||
});
|
});
|
||||||
|
|
||||||
// Support `export const components` for `MDX` pages
|
// Support `export const components` for `MDX` pages
|
||||||
|
|
|
@ -15,7 +15,7 @@ describe('404 and 500 pages', () => {
|
||||||
},
|
},
|
||||||
adapter: testAdapter(),
|
adapter: testAdapter(),
|
||||||
});
|
});
|
||||||
await fixture.build({ });
|
await fixture.build({});
|
||||||
});
|
});
|
||||||
|
|
||||||
it('404 page returned when a route does not match', async () => {
|
it('404 page returned when a route does not match', async () => {
|
||||||
|
|
Loading…
Reference in a new issue