Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: include routes in functions config on deploy #6027

Merged
merged 5 commits into from
Sep 28, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions src/utils/deploy/hash-fns.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -123,9 +123,12 @@ const hashFns = async (
}),
)
const fnConfig = functionZips
.filter((func) => Boolean(func.displayName || func.generator))
.filter((func) => Boolean(func.displayName || func.generator || func.routes))
.reduce(
(funcs, curr) => ({ ...funcs, [curr.name]: { display_name: curr.displayName, generator: curr.generator } }),
(funcs, curr) => ({
...funcs,
[curr.name]: { display_name: curr.displayName, generator: curr.generator, routes: curr.routes },
}),
{},
)
const functionSchedules = functionZips
Expand Down
12 changes: 9 additions & 3 deletions tests/integration/210.command.deploy.test.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ const { join } = require('path')
const process = require('process')

const test = require('ava')
const { Response } = require('node-fetch')
const { Response, default: fetch } = require('node-fetch')

const callCli = require('./utils/call-cli.cjs')
const { createLiveTestSite, generateSiteName } = require('./utils/create-live-test-site.cjs')
Expand Down Expand Up @@ -476,7 +476,10 @@ if (process.env.NETLIFY_TEST_DISABLE_LIVE !== 'true') {
}),
})
.withContentFile({
content: `export default async () => new Response("Internal V2 API")`,
content: `
export default async () => new Response("Internal V2 API")
export const config = { path: "/internal-v2-func" }
`,
path: '.netlify/functions-internal/func-4.mjs',
})
.buildAsync()
Expand All @@ -493,7 +496,10 @@ if (process.env.NETLIFY_TEST_DISABLE_LIVE !== 'true') {
t.is(await got(`${deployUrl}/.netlify/functions/func-1`).text(), 'User 1')
t.is(await got(`${deployUrl}/.netlify/functions/func-2`).text(), 'User 2')
t.is(await got(`${deployUrl}/.netlify/functions/func-3`).text(), 'Internal 3')
t.is(await got(`${deployUrl}/.netlify/functions/func-4`).text(), 'Internal V2 API')

const func4Resp = await fetch(`${deployUrl}/.netlify/functions/func-4`)
t.is(func4Resp.status, 404)
t.is(await got(`${deployUrl}/internal-v2-func`).text(), 'Internal V2 API')
})
})

Expand Down
Loading