Skip to content

Commit 7d2f311

Browse files
committed
feat: remove support for old API routes syntax (#7822)
1 parent 9a01cc6 commit 7d2f311

2 files changed

Lines changed: 6 additions & 26 deletions

File tree

.changeset/mighty-dancers-lay.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'astro': major
3+
---
4+
5+
Removed support for old syntax of the API routes.

packages/astro/src/runtime/server/endpoint.ts

Lines changed: 1 addition & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ export async function renderEndpoint(
4545
ssr: boolean,
4646
logging: LogOptions
4747
) {
48-
const { request, params } = context;
48+
const { request } = context;
4949

5050
const chosenMethod = request.method?.toUpperCase();
5151
const handler = getHandlerFromModule(mod, chosenMethod, logging);
@@ -68,35 +68,10 @@ ${chosenMethod} requests are not available when building a static site. Update y
6868
return response;
6969
}
7070

71-
// TODO: Remove support for old API in Astro 3.0
72-
if (handler.length > 1) {
73-
// eslint-disable-next-line no-console
74-
console.warn(`
75-
API routes with 2 arguments have been deprecated. Instead they take a single argument in the form of:
76-
77-
export function get({ params, request }) {
78-
//...
79-
}
80-
81-
Update your code to remove this warning.`);
82-
}
83-
8471
const proxy = new Proxy(context, {
8572
get(target, prop) {
8673
if (prop in target) {
8774
return Reflect.get(target, prop);
88-
} else if (prop in params) {
89-
// TODO: Remove support for old API in Astro 3.0
90-
// eslint-disable-next-line no-console
91-
console.warn(`
92-
API routes no longer pass params as the first argument. Instead an object containing a params property is provided in the form of:
93-
94-
export function get({ params }) {
95-
// ...
96-
}
97-
98-
Update your code to remove this warning.`);
99-
return Reflect.get(params, prop);
10075
} else {
10176
return undefined;
10277
}

0 commit comments

Comments
 (0)