diff options
author | 2023-10-12 14:39:45 +0000 | |
---|---|---|
committer | 2023-10-12 14:39:45 +0000 | |
commit | 45ae41a457b1fa54955e40fb8f588a8a54da0bf3 (patch) | |
tree | f009b09a267ea4453e126d895d2c64ab9b3ff1cd | |
parent | 391729686bcc8404a7dd48c5987ee380daf3200f (diff) | |
download | astro-45ae41a457b1fa54955e40fb8f588a8a54da0bf3.tar.gz astro-45ae41a457b1fa54955e40fb8f588a8a54da0bf3.tar.zst astro-45ae41a457b1fa54955e40fb8f588a8a54da0bf3.zip |
[ci] format
-rw-r--r-- | packages/astro/src/core/endpoint/index.ts | 28 | ||||
-rw-r--r-- | packages/integrations/node/test/locals.test.js | 4 |
2 files changed, 16 insertions, 16 deletions
diff --git a/packages/astro/src/core/endpoint/index.ts b/packages/astro/src/core/endpoint/index.ts index 7e6128c37..751643dd4 100644 --- a/packages/astro/src/core/endpoint/index.ts +++ b/packages/astro/src/core/endpoint/index.ts @@ -60,27 +60,27 @@ export function createAPIContext({ if (clientAddressSymbol in request) { return Reflect.get(request, clientAddressSymbol) as string; } - if (adapterName) { - throw new AstroError({ - ...AstroErrorData.ClientAddressNotAvailable, - message: AstroErrorData.ClientAddressNotAvailable.message(adapterName), - }); - } else { - throw new AstroError(AstroErrorData.StaticClientAddressNotAvailable); - } + if (adapterName) { + throw new AstroError({ + ...AstroErrorData.ClientAddressNotAvailable, + message: AstroErrorData.ClientAddressNotAvailable.message(adapterName), + }); + } else { + throw new AstroError(AstroErrorData.StaticClientAddressNotAvailable); + } }, get locals() { - let locals = Reflect.get(request, clientLocalsSymbol) - + let locals = Reflect.get(request, clientLocalsSymbol); + if (locals === undefined) { - locals = {} - Reflect.set(request, clientLocalsSymbol, locals) + locals = {}; + Reflect.set(request, clientLocalsSymbol, locals); } - + if (typeof locals !== 'object') { throw new AstroError(AstroErrorData.LocalsNotAnObject); } - + return locals; }, // We define a custom property, so we can check the value passed to locals diff --git a/packages/integrations/node/test/locals.test.js b/packages/integrations/node/test/locals.test.js index b593f3eb9..bba8b2d34 100644 --- a/packages/integrations/node/test/locals.test.js +++ b/packages/integrations/node/test/locals.test.js @@ -37,7 +37,7 @@ describe('API routes', () => { url: '/from-node-middleware', }); - handler(req, res, undefined, "locals"); + handler(req, res, undefined, 'locals'); req.send(); await done; @@ -46,7 +46,7 @@ describe('API routes', () => { it('Can use locals added by astro middleware', async () => { const { handler } = await import('./fixtures/locals/dist/server/entry.mjs'); - + const { req, res, text } = createRequestAndResponse({ url: '/from-astro-middleware', }); |