0
Fork 0
mirror of https://github.com/withastro/astro.git synced 2025-02-03 22:29:08 -05:00

[ci] format

This commit is contained in:
natemoo-re 2023-10-12 14:39:45 +00:00 committed by astrobot-houston
parent 391729686b
commit 45ae41a457
2 changed files with 16 additions and 16 deletions

View file

@ -60,27 +60,27 @@ export function createAPIContext({
if (clientAddressSymbol in request) { if (clientAddressSymbol in request) {
return Reflect.get(request, clientAddressSymbol) as string; return Reflect.get(request, clientAddressSymbol) as string;
} }
if (adapterName) { if (adapterName) {
throw new AstroError({ throw new AstroError({
...AstroErrorData.ClientAddressNotAvailable, ...AstroErrorData.ClientAddressNotAvailable,
message: AstroErrorData.ClientAddressNotAvailable.message(adapterName), message: AstroErrorData.ClientAddressNotAvailable.message(adapterName),
}); });
} else { } else {
throw new AstroError(AstroErrorData.StaticClientAddressNotAvailable); throw new AstroError(AstroErrorData.StaticClientAddressNotAvailable);
} }
}, },
get locals() { get locals() {
let locals = Reflect.get(request, clientLocalsSymbol) let locals = Reflect.get(request, clientLocalsSymbol);
if (locals === undefined) { if (locals === undefined) {
locals = {} locals = {};
Reflect.set(request, clientLocalsSymbol, locals) Reflect.set(request, clientLocalsSymbol, locals);
} }
if (typeof locals !== 'object') { if (typeof locals !== 'object') {
throw new AstroError(AstroErrorData.LocalsNotAnObject); throw new AstroError(AstroErrorData.LocalsNotAnObject);
} }
return locals; return locals;
}, },
// We define a custom property, so we can check the value passed to locals // We define a custom property, so we can check the value passed to locals

View file

@ -37,7 +37,7 @@ describe('API routes', () => {
url: '/from-node-middleware', url: '/from-node-middleware',
}); });
handler(req, res, undefined, "locals"); handler(req, res, undefined, 'locals');
req.send(); req.send();
await done; await done;
@ -46,7 +46,7 @@ describe('API routes', () => {
it('Can use locals added by astro middleware', async () => { it('Can use locals added by astro middleware', async () => {
const { handler } = await import('./fixtures/locals/dist/server/entry.mjs'); const { handler } = await import('./fixtures/locals/dist/server/entry.mjs');
const { req, res, text } = createRequestAndResponse({ const { req, res, text } = createRequestAndResponse({
url: '/from-astro-middleware', url: '/from-astro-middleware',
}); });