Skip to content

Commit

Permalink
[ci] format
Browse files Browse the repository at this point in the history
  • Loading branch information
matthewp authored and astrobot-houston committed Jul 22, 2022
1 parent 0cc6ede commit c17efc1
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 11 deletions.
19 changes: 12 additions & 7 deletions packages/astro/src/core/app/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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 {}
}
Expand Down Expand Up @@ -159,7 +164,7 @@ export class App {
ssr: true,
request,
streaming: this.#streaming,
status
status,
});

return response;
Expand Down Expand Up @@ -188,7 +193,7 @@ export class App {
route: routeData,
routeCache: this.#routeCache,
ssr: true,
status
status,
});

if (result.type === 'response') {
Expand Down
11 changes: 10 additions & 1 deletion packages/astro/src/core/endpoint/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 =
Expand Down
4 changes: 2 additions & 2 deletions packages/astro/src/core/render/core.ts
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ export async function render(opts: RenderOptions): Promise<Response> {
site,
ssr,
streaming,
status = 200
status = 200,
} = opts;

const paramsAndPropsRes = await getParamsAndProps({
Expand Down Expand Up @@ -150,7 +150,7 @@ export async function render(opts: RenderOptions): Promise<Response> {
scripts,
ssr,
streaming,
status
status,
});

// Support `export const components` for `MDX` pages
Expand Down
2 changes: 1 addition & 1 deletion packages/astro/test/ssr-404-500-pages.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 () => {
Expand Down

0 comments on commit c17efc1

Please sign in to comment.