diff --git a/packages/integrations/netlify/src/index.ts b/packages/integrations/netlify/src/index.ts index 121495652..beb3d0e0c 100644 --- a/packages/integrations/netlify/src/index.ts +++ b/packages/integrations/netlify/src/index.ts @@ -1,8 +1,3 @@ -export { - netlifyFunctions, - netlifyFunctions as default -} from './integration-functions.js'; +export { netlifyFunctions, netlifyFunctions as default } from './integration-functions.js'; -export { - netlifyEdgeFunctions -} from './integration-edge-functions.js'; +export { netlifyEdgeFunctions } from './integration-edge-functions.js'; diff --git a/packages/integrations/netlify/src/integration-edge-functions.ts b/packages/integrations/netlify/src/integration-edge-functions.ts index fcce820f4..c607a5493 100644 --- a/packages/integrations/netlify/src/integration-edge-functions.ts +++ b/packages/integrations/netlify/src/integration-edge-functions.ts @@ -23,7 +23,9 @@ interface NetlifyEdgeFunctionManifestFunctionPattern { pattern: string; } -type NetlifyEdgeFunctionManifestFunction = NetlifyEdgeFunctionManifestFunctionPath | NetlifyEdgeFunctionManifestFunctionPattern; +type NetlifyEdgeFunctionManifestFunction = + | NetlifyEdgeFunctionManifestFunctionPath + | NetlifyEdgeFunctionManifestFunctionPattern; interface NetlifyEdgeFunctionManifest { functions: NetlifyEdgeFunctionManifestFunction[]; @@ -32,28 +34,28 @@ interface NetlifyEdgeFunctionManifest { async function createEdgeManifest(routes: RouteData[], entryFile: string, dir: URL) { const functions: NetlifyEdgeFunctionManifestFunction[] = []; - for(const route of routes) { - if(route.pathname) { - functions.push({ - function: entryFile, - path: route.pathname - }); - } else { - functions.push({ - function: entryFile, - pattern: route.pattern.source - }); - } - } + for (const route of routes) { + if (route.pathname) { + functions.push({ + function: entryFile, + path: route.pathname, + }); + } else { + functions.push({ + function: entryFile, + pattern: route.pattern.source, + }); + } + } - const manifest: NetlifyEdgeFunctionManifest = { - functions, - version: 1 - }; + const manifest: NetlifyEdgeFunctionManifest = { + functions, + version: 1, + }; - const manifestURL = new URL('./manifest.json', dir); - const _manifest = JSON.stringify(manifest, null, ' '); - await fs.promises.writeFile(manifestURL, _manifest, 'utf-8'); + const manifestURL = new URL('./manifest.json', dir); + const _manifest = JSON.stringify(manifest, null, ' '); + await fs.promises.writeFile(manifestURL, _manifest, 'utf-8'); } export function netlifyEdgeFunctions({ dist }: NetlifyEdgeFunctionsOptions = {}): AstroIntegration { @@ -86,13 +88,10 @@ export function netlifyEdgeFunctions({ dist }: NetlifyEdgeFunctionsOptions = {}) } }, 'astro:build:done': async ({ routes, dir }) => { - await createEdgeManifest(routes, entryFile, new URL('./edge-functions/', dir)); }, }, }; } -export { - netlifyEdgeFunctions as default -} +export { netlifyEdgeFunctions as default }; diff --git a/packages/integrations/netlify/src/netlify-edge-functions.ts b/packages/integrations/netlify/src/netlify-edge-functions.ts index f7000442c..1bb8e2c3a 100644 --- a/packages/integrations/netlify/src/netlify-edge-functions.ts +++ b/packages/integrations/netlify/src/netlify-edge-functions.ts @@ -6,15 +6,15 @@ export function createExports(manifest: SSRManifest) { const app = new App(manifest); const handler = async (request: Request): Promise => { - if(app.match(request)) { + if (app.match(request)) { return app.render(request); } return new Response(null, { status: 404, - statusText: 'Not found' + statusText: 'Not found', }); }; - return { 'default': handler }; + return { default: handler }; } diff --git a/packages/integrations/netlify/test/edge-functions/edge-basic.test.ts b/packages/integrations/netlify/test/edge-functions/edge-basic.test.ts index a99125980..7fc8877bd 100644 --- a/packages/integrations/netlify/test/edge-functions/edge-basic.test.ts +++ b/packages/integrations/netlify/test/edge-functions/edge-basic.test.ts @@ -8,7 +8,9 @@ Deno.test({ name: 'Edge Basics', async fn() { let close = await runBuild('./fixtures/edge-basic/'); - const { default: handler } = await import('./fixtures/edge-basic/dist/edge-functions/entry.mjs'); + const { default: handler } = await import( + './fixtures/edge-basic/dist/edge-functions/entry.mjs' + ); const response = await handler(new Request('http://example.com/')); assertEquals(response.status, 200); const html = await response.text(); diff --git a/packages/integrations/netlify/test/functions/cookies.test.js b/packages/integrations/netlify/test/functions/cookies.test.js index 93cc05229..43c55916b 100644 --- a/packages/integrations/netlify/test/functions/cookies.test.js +++ b/packages/integrations/netlify/test/functions/cookies.test.js @@ -18,7 +18,7 @@ describe('Cookies', () => { dist: new URL('./fixtures/cookies/dist/', import.meta.url), }), site: `http://example.com`, - integrations: [ testIntegration() ] + integrations: [testIntegration()], }); await fixture.build(); }); diff --git a/packages/integrations/netlify/test/functions/dynamic-route.test.js b/packages/integrations/netlify/test/functions/dynamic-route.test.js index 279982767..8c8977f7e 100644 --- a/packages/integrations/netlify/test/functions/dynamic-route.test.js +++ b/packages/integrations/netlify/test/functions/dynamic-route.test.js @@ -16,7 +16,7 @@ describe('Dynamic pages', () => { dist: new URL('./fixtures/dynamic-route/dist/', import.meta.url), }), site: `http://example.com`, - integrations: [ testIntegration() ] + integrations: [testIntegration()], }); await fixture.build(); }); diff --git a/packages/integrations/netlify/test/functions/test-utils.js b/packages/integrations/netlify/test/functions/test-utils.js index 19cd7ef66..02b5d2ad9 100644 --- a/packages/integrations/netlify/test/functions/test-utils.js +++ b/packages/integrations/netlify/test/functions/test-utils.js @@ -4,14 +4,14 @@ import { fileURLToPath } from 'url'; export * from '../../../../astro/test/test-utils.js'; /** - * + * * @returns {import('../../../../astro/dist/types/@types/astro').AstroIntegration} */ export function testIntegration() { return { name: '@astrojs/netlify/test-integration', hooks: { - 'astro:config:setup':({ updateConfig }) => { + 'astro:config:setup': ({ updateConfig }) => { updateConfig({ vite: { resolve: { @@ -23,7 +23,7 @@ export function testIntegration() { }, }, }); - } - } + }, + }, }; }