Skip to content

Commit

Permalink
feat: remove deprecation
Browse files Browse the repository at this point in the history
  • Loading branch information
ematipico committed Jul 26, 2023
1 parent e2fbe01 commit 5f3ae59
Showing 1 changed file with 1 addition and 26 deletions.
27 changes: 1 addition & 26 deletions packages/astro/src/runtime/server/endpoint.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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;
}
Expand Down

0 comments on commit 5f3ae59

Please sign in to comment.