Skip to content
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
513 changes: 404 additions & 109 deletions package-lock.json

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@
"envinfo": "7.15.0",
"etag": "1.8.1",
"execa": "5.1.1",
"express": "4.22.1",
"express": "5.2.1",
"express-logging": "1.1.1",
"extract-zip": "2.0.1",
"fastest-levenshtein": "1.0.16",
Expand All @@ -111,7 +111,7 @@
"git-repo-info": "2.1.1",
"gitconfiglocal": "2.1.0",
"http-proxy": "1.18.1",
"http-proxy-middleware": "2.0.9",
"http-proxy-middleware": "3.0.5",
"https-proxy-agent": "7.0.6",
"inquirer": "8.2.7",
"inquirer-autocomplete-prompt": "1.4.0",
Expand Down Expand Up @@ -169,7 +169,7 @@
"@types/envinfo": "7.8.4",
"@types/eslint-config-prettier": "6.11.3",
"@types/etag": "1.8.4",
"@types/express": "4.17.25",
"@types/express": "5.0.6",
"@types/folder-walker": "3.2.4",
"@types/gitconfiglocal": "2.0.3",
"@types/inquirer": "9.0.9",
Expand Down
2 changes: 1 addition & 1 deletion src/lib/functions/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -293,7 +293,7 @@ const getFunctionsServer = (options: GetFunctionsServerOptions) => {
}),
)

app.all('*', functionHandler)
app.all('{*splat}', functionHandler)

return app
}
Expand Down
5 changes: 1 addition & 4 deletions src/utils/proxy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -192,12 +192,9 @@ const proxyToExternalUrl = function ({
target: dest.origin,
changeOrigin: true,
pathRewrite: () => destURL,
// hide logging
logLevel: 'warn',
...(Buffer.isBuffer(req.originalBody) && { buffer: Readable.from(req.originalBody) }),
})
// @ts-expect-error TS(2345) FIXME: Argument of type 'Request' is not assignable to parameter of type 'Request<ParamsDictionary, any, any, ParsedQs, Record<string, any>>'.
handler(req, res, () => {})
void handler(req, res, () => {})
}

// @ts-expect-error TS(7031) FIXME: Binding element 'addonUrl' implicitly has an 'any'... Remove this comment to see the full error message
Expand Down
2 changes: 1 addition & 1 deletion tests/integration/commands/blobs/blobs.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ describe('blobs:* commands', () => {

routes.push({
method: 'all',
path: 'blobs/*',
path: 'blobs/{*splat}',
response: (req, res) => {
blobsProxy.web(req, res, { target: `http://localhost:${address.port}` })
},
Expand Down
2 changes: 0 additions & 2 deletions tests/integration/commands/dev/dev.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,6 @@ describe.concurrent('command/dev', () => {
await withDevServer({ cwd: builder.directory }, async (server) => {
const getResponse = await fetch(`${server.url}/api/ping`)
const jsonPingWithGet = await getResponse.json()
t.expect(jsonPingWithGet).toHaveProperty('body', {})
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

req.body defaults to undefined instead of {} when no body parser matches now. I deleted the assertions instead of updating them because there's nothing valuable to test here — GETs don't have request bodies.

(If you're confused that this appears to be a response body, it's because the test is setting up a Function that echoes back some request fields.)

t.expect(jsonPingWithGet).toHaveProperty('method', 'GET')
t.expect(jsonPingWithGet).toHaveProperty('url', '/ping')

Expand Down Expand Up @@ -354,7 +353,6 @@ describe.concurrent('command/dev', () => {
const response2Body = await response2.json()
t.expect(response1.headers.get('location')).toEqual(`http://localhost:${port.toString()}/ping`)

t.expect(response2Body).toHaveProperty('body', {})
t.expect(response2Body).toHaveProperty('method', 'GET')
t.expect(response2Body).toHaveProperty('url', '/ping')
})
Expand Down
4 changes: 2 additions & 2 deletions tests/integration/commands/dev/v2-api.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ const siteInfo = {
name: 'mock-site-name',
}
const routes = [
{ path: 'sites/*/service-instances', response: [] },
{ path: 'sites/*', response: siteInfo },
{ path: 'sites/:siteId/service-instances', response: [] },
{ path: 'sites/{*splat}', response: siteInfo },
{
path: 'accounts',
response: [{ id: siteInfo.account_id, slug: siteInfo.account_slug }],
Expand Down
2 changes: 1 addition & 1 deletion tests/integration/utils/external-server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import express from 'express'
export const startExternalServer = ({ host, port }: { host?: string | undefined; port?: number | undefined } = {}) => {
const app = express()
app.use(express.urlencoded({ extended: true }))
app.all('*', function onRequest(req, res) {
app.all('{*splat}', function onRequest(req, res) {
res.json({
url: req.url,
body: req.body as string,
Expand Down
2 changes: 1 addition & 1 deletion tests/integration/utils/mock-api-vitest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ export const startMockApi = ({ routes, silent }: MockApiOptions): Promise<MockAp
)
})

app.all('*', function onRequest(req, res) {
app.all('{*splat}', function onRequest(req, res) {
addRequest(requests, req)
if (!silent) {
console.warn(`Route not found: (${req.method.toUpperCase()}) ${req.url}`)
Expand Down
2 changes: 1 addition & 1 deletion tests/integration/utils/mock-api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ export const startMockApi = ({ routes, silent }: MockApiOptions): Promise<MockAp
res.json([])
})

app.all('*', function onRequest(req, res) {
app.all('{*splat}', function onRequest(req, res) {
if (process.env.DEBUG_TESTS) {
console.debug('[mock-api] ', req.method, req.path, req.body)
}
Expand Down
2 changes: 1 addition & 1 deletion tests/unit/lib/functions/server.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ describe('createHandler', () => {

// TODO(serhalp): Lazy test type. Create a config factory and use it here.
app.all(
'*',
'{*splat}',
// @ts-expect-error TS(2741) FIXME: Property 'processing' is missing in type '{}' but ... Remove this comment to see the full error message
createHandler({ functionsRegistry, config: { dev: {} }, geo: 'mock', state: new LocalState(projectRoot) }),
)
Expand Down
Loading