[ci] format

This commit is contained in:
matthewp 2022-05-04 18:56:21 +00:00 committed by github-actions[bot]
parent 6643a3931d
commit e087f27a9b
2 changed files with 10 additions and 10 deletions

View file

@ -470,7 +470,7 @@ export async function renderEndpoint(mod: EndpointHandler, request: Request, par
);
}
if(handler.length > 1) {
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:
@ -479,19 +479,19 @@ export function get({ params, request }) {
//...
}
Update your code to remove this warning.`)
Update your code to remove this warning.`);
}
const context = {
request,
params
params,
};
const proxy = new Proxy(context, {
get(target, prop) {
if(prop in target) {
if (prop in target) {
return Reflect.get(target, prop);
} else if(prop in params) {
} else if (prop in params) {
// 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:
@ -505,7 +505,7 @@ Update your code to remove this warning.`);
} else {
return undefined;
}
}
},
}) as APIContext & Params;
return await handler.call(mod, proxy, request);

View file

@ -15,19 +15,19 @@ describe('API routes', () => {
const one = JSON.parse(await fixture.readFile('/old-api/twoarg/one.json'));
expect(one).to.deep.equal({
param: 'one',
pathname: '/old-api/twoarg/one.json'
pathname: '/old-api/twoarg/one.json',
});
const two = JSON.parse(await fixture.readFile('/old-api/twoarg/two.json'));
expect(two).to.deep.equal({
param: 'two',
pathname: '/old-api/twoarg/two.json'
pathname: '/old-api/twoarg/two.json',
});
});
it('param first argument is supported', async () => {
const one = JSON.parse(await fixture.readFile('/old-api/onearg/one.json'));
expect(one).to.deep.equal({
param: 'one'
param: 'one',
});
});
});
@ -37,7 +37,7 @@ describe('API routes', () => {
const one = JSON.parse(await fixture.readFile('/context/data/one.json'));
expect(one).to.deep.equal({
param: 'one',
pathname: '/context/data/one.json'
pathname: '/context/data/one.json',
});
});
});