From 0b1c57d71710d45c55d483c4ef37c0ce8348b566 Mon Sep 17 00:00:00 2001 From: Alexander Niebuhr Date: Tue, 28 Nov 2023 17:15:59 +0100 Subject: [PATCH 1/4] chore: remove `matchNotFound` from `app.match()` --- .changeset/weak-wolves-bow.md | 5 +++++ packages/astro/src/core/app/index.ts | 1 - packages/astro/test/middleware.test.js | 4 ++-- packages/astro/test/ssr-404-500-pages.test.js | 2 +- 4 files changed, 8 insertions(+), 4 deletions(-) create mode 100644 .changeset/weak-wolves-bow.md diff --git a/.changeset/weak-wolves-bow.md b/.changeset/weak-wolves-bow.md new file mode 100644 index 000000000000..cd0aa1887784 --- /dev/null +++ b/.changeset/weak-wolves-bow.md @@ -0,0 +1,5 @@ +--- +'astro': patch +--- + +Removes depreacted `app.match()` option, `matchNotFound` diff --git a/packages/astro/src/core/app/index.ts b/packages/astro/src/core/app/index.ts index 3e72c3810e21..62c9d7a41d6b 100644 --- a/packages/astro/src/core/app/index.ts +++ b/packages/astro/src/core/app/index.ts @@ -36,7 +36,6 @@ const responseSentSymbol = Symbol.for('astro.responseSent'); const STATUS_CODES = new Set([404, 500]); export interface MatchOptions { - matchNotFound?: boolean | undefined; } export interface RenderErrorOptions { routeData?: RouteData; diff --git a/packages/astro/test/middleware.test.js b/packages/astro/test/middleware.test.js index 5b033ca4dc02..a6745f176543 100644 --- a/packages/astro/test/middleware.test.js +++ b/packages/astro/test/middleware.test.js @@ -251,7 +251,7 @@ describe('Middleware API in PROD mode, SSR', () => { it('should correctly call the middleware function for 404', async () => { const request = new Request('http://example.com/funky-url'); - const routeData = app.match(request, { matchNotFound: true }); + const routeData = app.match(request); const response = await app.render(request, routeData); const text = await response.text(); expect(text.includes('Error')).to.be.true; @@ -260,7 +260,7 @@ describe('Middleware API in PROD mode, SSR', () => { it('should render 500.astro when the middleware throws an error', async () => { const request = new Request('http://example.com/throw'); - const routeData = app.match(request, { matchNotFound: true }); + const routeData = app.match(request); const response = await app.render(request, routeData); expect(response).to.deep.include({ status: 500 }); diff --git a/packages/astro/test/ssr-404-500-pages.test.js b/packages/astro/test/ssr-404-500-pages.test.js index 253f9bc1ca99..1c735e88995d 100644 --- a/packages/astro/test/ssr-404-500-pages.test.js +++ b/packages/astro/test/ssr-404-500-pages.test.js @@ -56,7 +56,7 @@ describe('404 and 500 pages', () => { it('404 page returned when a route does not match and passing routeData', async () => { const app = await fixture.loadTestAdapterApp(); const request = new Request('http://example.com/some/fake/route'); - const routeData = app.match(request, { matchNotFound: true }); + const routeData = app.match(request); const response = await app.render(request, routeData); expect(response.status).to.equal(404); const html = await response.text(); From e1f4d47d06c11bbd51d5b866d3d200e1a0a9177c Mon Sep 17 00:00:00 2001 From: Alexander Niebuhr Date: Wed, 29 Nov 2023 08:06:21 +0100 Subject: [PATCH 2/4] address review comments --- packages/astro/src/core/app/index.ts | 4 +--- packages/astro/src/core/app/node.ts | 6 +++--- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/packages/astro/src/core/app/index.ts b/packages/astro/src/core/app/index.ts index 62c9d7a41d6b..aa89c8286804 100644 --- a/packages/astro/src/core/app/index.ts +++ b/packages/astro/src/core/app/index.ts @@ -35,8 +35,6 @@ const responseSentSymbol = Symbol.for('astro.responseSent'); const STATUS_CODES = new Set([404, 500]); -export interface MatchOptions { -} export interface RenderErrorOptions { routeData?: RouteData; response?: Response; @@ -132,7 +130,7 @@ export class App { return pathname; } - match(request: Request, _opts: MatchOptions = {}): RouteData | undefined { + match(request: Request): RouteData | undefined { const url = new URL(request.url); // ignore requests matching public assets if (this.#manifest.assets.has(url.pathname)) return undefined; diff --git a/packages/astro/src/core/app/node.ts b/packages/astro/src/core/app/node.ts index 1df931eca22e..a127b9831c1a 100644 --- a/packages/astro/src/core/app/node.ts +++ b/packages/astro/src/core/app/node.ts @@ -5,7 +5,7 @@ import * as fs from 'node:fs'; import { IncomingMessage } from 'node:http'; import { TLSSocket } from 'node:tls'; import { deserializeManifest } from './common.js'; -import { App, type MatchOptions } from './index.js'; +import { App } from './index.js'; export { apply as applyPolyfills } from '../polyfill.js'; const clientAddressSymbol = Symbol.for('astro.clientAddress'); @@ -108,13 +108,13 @@ class NodeIncomingMessage extends IncomingMessage { } export class NodeApp extends App { - match(req: NodeIncomingMessage | Request, opts: MatchOptions = {}) { + match(req: NodeIncomingMessage | Request) { if (!(req instanceof Request)) { req = createRequestFromNodeRequest(req, { emptyBody: true, }); } - return super.match(req, opts); + return super.match(req); } render(req: NodeIncomingMessage | Request, routeData?: RouteData, locals?: object) { if (!(req instanceof Request)) { From 232e87d4e09856b6b92eba6a3de4210787afd772 Mon Sep 17 00:00:00 2001 From: Alexander Niebuhr Date: Wed, 29 Nov 2023 08:07:24 +0100 Subject: [PATCH 3/4] Update .changeset/weak-wolves-bow.md Co-authored-by: Matthew Phillips --- .changeset/weak-wolves-bow.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.changeset/weak-wolves-bow.md b/.changeset/weak-wolves-bow.md index cd0aa1887784..eed35e32d8ee 100644 --- a/.changeset/weak-wolves-bow.md +++ b/.changeset/weak-wolves-bow.md @@ -1,5 +1,5 @@ --- -'astro': patch +'astro': major --- Removes depreacted `app.match()` option, `matchNotFound` From dd64b44bb7f9c3e59d3c50fe65a70bd9eb571645 Mon Sep 17 00:00:00 2001 From: Alexander Niebuhr Date: Wed, 29 Nov 2023 08:07:33 +0100 Subject: [PATCH 4/4] Update .changeset/weak-wolves-bow.md Co-authored-by: Matthew Phillips --- .changeset/weak-wolves-bow.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.changeset/weak-wolves-bow.md b/.changeset/weak-wolves-bow.md index eed35e32d8ee..484544cd12b7 100644 --- a/.changeset/weak-wolves-bow.md +++ b/.changeset/weak-wolves-bow.md @@ -2,4 +2,4 @@ 'astro': major --- -Removes depreacted `app.match()` option, `matchNotFound` +Removes deprecated `app.match()` option, `matchNotFound`