mirror of
https://github.com/withastro/astro.git
synced 2024-12-16 21:46:22 -05:00
[ci] format
This commit is contained in:
parent
4cf54c60aa
commit
13b1bdd972
7 changed files with 38 additions and 42 deletions
|
@ -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';
|
||||
|
|
|
@ -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 };
|
||||
|
|
|
@ -6,15 +6,15 @@ export function createExports(manifest: SSRManifest) {
|
|||
const app = new App(manifest);
|
||||
|
||||
const handler = async (request: Request): Promise<Response> => {
|
||||
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 };
|
||||
}
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -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();
|
||||
});
|
||||
|
|
|
@ -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();
|
||||
});
|
||||
|
|
|
@ -11,7 +11,7 @@ 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() {
|
|||
},
|
||||
},
|
||||
});
|
||||
}
|
||||
}
|
||||
},
|
||||
},
|
||||
};
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue