From 7d2f311d428e3d1c8c13b9bf2a708d6435713fc2 Mon Sep 17 00:00:00 2001 From: Emanuele Stoppa Date: Thu, 27 Jul 2023 10:20:13 +0100 Subject: [PATCH] feat: remove support for old API routes syntax (#7822) --- .changeset/mighty-dancers-lay.md | 5 ++++ packages/astro/src/runtime/server/endpoint.ts | 27 +------------------ 2 files changed, 6 insertions(+), 26 deletions(-) create mode 100644 .changeset/mighty-dancers-lay.md diff --git a/.changeset/mighty-dancers-lay.md b/.changeset/mighty-dancers-lay.md new file mode 100644 index 000000000..873c4edd1 --- /dev/null +++ b/.changeset/mighty-dancers-lay.md @@ -0,0 +1,5 @@ +--- +'astro': major +--- + +Removed support for old syntax of the API routes. diff --git a/packages/astro/src/runtime/server/endpoint.ts b/packages/astro/src/runtime/server/endpoint.ts index 560026313..89c35957c 100644 --- a/packages/astro/src/runtime/server/endpoint.ts +++ b/packages/astro/src/runtime/server/endpoint.ts @@ -45,7 +45,7 @@ export async function renderEndpoint( ssr: boolean, logging: LogOptions ) { - const { request, params } = context; + const { request } = context; const chosenMethod = request.method?.toUpperCase(); const handler = getHandlerFromModule(mod, chosenMethod, logging); @@ -68,35 +68,10 @@ ${chosenMethod} requests are not available when building a static site. Update y return response; } - // TODO: Remove support for old API in Astro 3.0 - if (handler.length > 1) { - // eslint-disable-next-line no-console - console.warn(` -API routes with 2 arguments have been deprecated. Instead they take a single argument in the form of: - -export function get({ params, request }) { - //... -} - -Update your code to remove this warning.`); - } - const proxy = new Proxy(context, { get(target, prop) { if (prop in target) { return Reflect.get(target, prop); - } else if (prop in params) { - // TODO: Remove support for old API in Astro 3.0 - // eslint-disable-next-line no-console - console.warn(` -API routes no longer pass params as the first argument. Instead an object containing a params property is provided in the form of: - -export function get({ params }) { - // ... -} - -Update your code to remove this warning.`); - return Reflect.get(params, prop); } else { return undefined; }