netlify-cli 17.15.0 → 17.15.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/commands/dev/dev.d.ts.map +1 -1
- package/dist/commands/dev/dev.js +0 -1
- package/dist/commands/functions/functions-serve.d.ts.map +1 -1
- package/dist/commands/functions/functions-serve.js +8 -4
- package/dist/commands/serve/serve.d.ts.map +1 -1
- package/dist/commands/serve/serve.js +0 -1
- package/dist/lib/functions/form-submissions-handler.d.ts +6 -4
- package/dist/lib/functions/form-submissions-handler.d.ts.map +1 -1
- package/dist/lib/functions/form-submissions-handler.js +3 -5
- package/dist/lib/functions/netlify-function.d.ts +1 -1
- package/dist/lib/functions/netlify-function.d.ts.map +1 -1
- package/dist/lib/functions/netlify-function.js +1 -1
- package/dist/lib/functions/registry.js +1 -1
- package/dist/lib/functions/server.d.ts +29 -18
- package/dist/lib/functions/server.d.ts.map +1 -1
- package/dist/lib/functions/server.js +24 -51
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/npm-shrinkwrap.json +792 -2070
- package/package.json +6 -6
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dev.d.ts","sourceRoot":"","sources":["../../../src/commands/dev/dev.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,YAAY,EAAU,MAAM,WAAW,CAAA;AA0BhD,OAAO,WAAW,MAAM,oBAAoB,CAAA;AA4D5C,eAAO,MAAM,GAAG,YAAmB,YAAY,WAAW,WAAW,
|
|
1
|
+
{"version":3,"file":"dev.d.ts","sourceRoot":"","sources":["../../../src/commands/dev/dev.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,YAAY,EAAU,MAAM,WAAW,CAAA;AA0BhD,OAAO,WAAW,MAAM,oBAAoB,CAAA;AA4D5C,eAAO,MAAM,GAAG,YAAmB,YAAY,WAAW,WAAW,kBA+IpE,CAAA;AAED,eAAO,MAAM,gBAAgB,YAAa,WAAW,gBAuGpD,CAAA"}
|
package/dist/commands/dev/dev.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"functions-serve.d.ts","sourceRoot":"","sources":["../../../src/commands/functions/functions-serve.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,YAAY,EAAE,MAAM,WAAW,CAAA;
|
|
1
|
+
{"version":3,"file":"functions-serve.d.ts","sourceRoot":"","sources":["../../../src/commands/functions/functions-serve.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,YAAY,EAAE,MAAM,WAAW,CAAA;AAcxC,OAAO,WAAW,MAAM,oBAAoB,CAAA;AAI5C,eAAO,MAAM,cAAc,YAAmB,YAAY,WAAW,WAAW,kBAkD/E,CAAA"}
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { join } from 'path';
|
|
2
|
+
import { getBlobsContext } from '../../lib/blobs/blobs.js';
|
|
2
3
|
import { startFunctionsServer } from '../../lib/functions/server.js';
|
|
3
4
|
import { printBanner } from '../../utils/banner.js';
|
|
4
|
-
import { acquirePort, getDotEnvVariables, getSiteInformation, injectEnvVariables } from '../../utils/dev.js';
|
|
5
|
+
import { UNLINKED_SITE_MOCK_ID, acquirePort, getDotEnvVariables, getSiteInformation, injectEnvVariables, } from '../../utils/dev.js';
|
|
5
6
|
import { getFunctionsDir } from '../../utils/functions/index.js';
|
|
6
7
|
import { getProxyUrl } from '../../utils/proxy.js';
|
|
7
8
|
const DEFAULT_PORT = 9999;
|
|
@@ -23,19 +24,22 @@ export const functionsServe = async (options, command) => {
|
|
|
23
24
|
defaultPort: DEFAULT_PORT,
|
|
24
25
|
errorMessage: 'Could not acquire configured functions port',
|
|
25
26
|
});
|
|
27
|
+
const blobsContext = await getBlobsContext({
|
|
28
|
+
debug: options.debug,
|
|
29
|
+
projectRoot: command.workingDir,
|
|
30
|
+
siteID: site.id ?? UNLINKED_SITE_MOCK_ID,
|
|
31
|
+
});
|
|
26
32
|
await startFunctionsServer({
|
|
33
|
+
blobsContext,
|
|
27
34
|
config,
|
|
28
35
|
debug: options.debug,
|
|
29
36
|
command,
|
|
30
|
-
api,
|
|
31
37
|
settings: { functions: functionsDir, functionsPort },
|
|
32
38
|
site,
|
|
33
39
|
siteInfo,
|
|
34
40
|
siteUrl,
|
|
35
41
|
capabilities,
|
|
36
42
|
timeouts,
|
|
37
|
-
functionsPrefix: '/.netlify/functions/',
|
|
38
|
-
buildersPrefix: '/.netlify/builders/',
|
|
39
43
|
geolocationMode: options.geo,
|
|
40
44
|
geoCountry: options.country,
|
|
41
45
|
offline: options.offline,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"serve.d.ts","sourceRoot":"","sources":["../../../src/commands/serve/serve.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,YAAY,EAAE,MAAM,WAAW,CAAA;AAwBxC,OAAO,WAAW,MAAM,oBAAoB,CAAA;AAG5C,eAAO,MAAM,KAAK,YAAmB,YAAY,WAAW,WAAW,
|
|
1
|
+
{"version":3,"file":"serve.d.ts","sourceRoot":"","sources":["../../../src/commands/serve/serve.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,YAAY,EAAE,MAAM,WAAW,CAAA;AAwBxC,OAAO,WAAW,MAAM,oBAAoB,CAAA;AAG5C,eAAO,MAAM,KAAK,YAAmB,YAAY,WAAW,WAAW,uBA2ItE,CAAA"}
|
|
@@ -1,5 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
import type { RequestHandler } from 'express';
|
|
2
|
+
import type { FunctionsRegistry } from './registry.js';
|
|
3
|
+
export declare const createFormSubmissionHandler: ({ functionsRegistry, siteUrl, }: {
|
|
4
|
+
functionsRegistry: FunctionsRegistry;
|
|
5
|
+
siteUrl: string;
|
|
6
|
+
}) => RequestHandler;
|
|
5
7
|
//# sourceMappingURL=form-submissions-handler.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"form-submissions-handler.d.ts","sourceRoot":"","sources":["../../../src/lib/functions/form-submissions-handler.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"form-submissions-handler.d.ts","sourceRoot":"","sources":["../../../src/lib/functions/form-submissions-handler.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,SAAS,CAAA;AAS7C,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,eAAe,CAAA;AAqBtD,eAAO,MAAM,2BAA2B;uBAInB,iBAAiB;aAC3B,MAAM;MACb,cAwIH,CAAA"}
|
|
@@ -22,13 +22,11 @@ const getFormHandler = function ({ functionsRegistry }) {
|
|
|
22
22
|
}
|
|
23
23
|
return handlers[0];
|
|
24
24
|
};
|
|
25
|
-
|
|
26
|
-
export const createFormSubmissionHandler = function ({ functionsRegistry, siteUrl }) {
|
|
27
|
-
// @ts-expect-error TS(7006) FIXME: Parameter 'req' implicitly has an 'any' type.
|
|
25
|
+
export const createFormSubmissionHandler = function ({ functionsRegistry, siteUrl, }) {
|
|
28
26
|
return async function formSubmissionHandler(req, res, next) {
|
|
29
27
|
if (req.url.startsWith('/.netlify/') ||
|
|
30
28
|
req.method !== 'POST' ||
|
|
31
|
-
(await functionsRegistry.getFunctionForURLPath(req.url, req.method)))
|
|
29
|
+
(await functionsRegistry.getFunctionForURLPath(req.url, req.method, () => Promise.resolve(false))))
|
|
32
30
|
return next();
|
|
33
31
|
const fakeRequest = new Readable({
|
|
34
32
|
read() {
|
|
@@ -137,7 +135,7 @@ export const createFormSubmissionHandler = function ({ functionsRegistry, siteUr
|
|
|
137
135
|
req.body = data;
|
|
138
136
|
req.headers = {
|
|
139
137
|
...req.headers,
|
|
140
|
-
'content-length': data.length,
|
|
138
|
+
'content-length': String(data.length),
|
|
141
139
|
'content-type': 'application/json',
|
|
142
140
|
'x-netlify-original-pathname': originalUrl.pathname,
|
|
143
141
|
'x-netlify-original-search': originalUrl.search,
|
|
@@ -9,7 +9,7 @@ export default class NetlifyFunction {
|
|
|
9
9
|
private readonly blobsContext;
|
|
10
10
|
private readonly timeoutBackground;
|
|
11
11
|
private readonly timeoutSynchronous;
|
|
12
|
-
|
|
12
|
+
readonly isBackground: boolean;
|
|
13
13
|
private buildQueue?;
|
|
14
14
|
private buildData?;
|
|
15
15
|
buildError: Error | null;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"netlify-function.d.ts","sourceRoot":"","sources":["../../../src/lib/functions/netlify-function.ts"],"names":[],"mappings":"AA2BA,MAAM,CAAC,OAAO,OAAO,eAAe;IAClC,SAAgB,IAAI,EAAE,MAAM,CAAA;IAC5B,SAAgB,QAAQ,EAAE,MAAM,CAAA;IAChC,SAAgB,WAAW,EAAE,MAAM,CAAA;IACnC,SAAgB,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjC,SAAgB,OAAO,EAAE,MAAM,CAAA;IAE/B,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAQ;IAClC,OAAO,CAAC,QAAQ,CAAC,WAAW,CAAQ;IACpC,OAAO,CAAC,QAAQ,CAAC,YAAY,CAAc;IAC3C,OAAO,CAAC,QAAQ,CAAC,iBAAiB,CAAQ;IAC1C,OAAO,CAAC,QAAQ,CAAC,kBAAkB,CAAQ;IAI3C,
|
|
1
|
+
{"version":3,"file":"netlify-function.d.ts","sourceRoot":"","sources":["../../../src/lib/functions/netlify-function.ts"],"names":[],"mappings":"AA2BA,MAAM,CAAC,OAAO,OAAO,eAAe;IAClC,SAAgB,IAAI,EAAE,MAAM,CAAA;IAC5B,SAAgB,QAAQ,EAAE,MAAM,CAAA;IAChC,SAAgB,WAAW,EAAE,MAAM,CAAA;IACnC,SAAgB,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjC,SAAgB,OAAO,EAAE,MAAM,CAAA;IAE/B,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAQ;IAClC,OAAO,CAAC,QAAQ,CAAC,WAAW,CAAQ;IACpC,OAAO,CAAC,QAAQ,CAAC,YAAY,CAAc;IAC3C,OAAO,CAAC,QAAQ,CAAC,iBAAiB,CAAQ;IAC1C,OAAO,CAAC,QAAQ,CAAC,kBAAkB,CAAQ;IAI3C,SAAgB,YAAY,EAAE,OAAO,CAAA;IAErC,OAAO,CAAC,UAAU,CAAC,CAAiB;IACpC,OAAO,CAAC,SAAS,CAAC,CAAQ;IACnB,UAAU,EAAE,KAAK,GAAG,IAAI,CAAO;IAItC,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAoB;gBAEjC,EAEV,YAAY,EAEZ,MAAM,EAEN,SAAS,EAET,WAAW,EAEX,QAAQ,EAER,IAAI,EAEJ,WAAW,EAEX,OAAO,EAEP,QAAQ,EAER,iBAAiB,EAEjB,kBAAkB,GACnB;;;;;;;;;;;;KAAA;IAuBD,IAAI,QAAQ,kBAMX;IAED,uBAAuB;IAqBvB,YAAY;IAMN,WAAW;IAMjB,WAAW;IAIX,YAAY;IAQN,UAAU;IAeV,KAAK,CAAC,EAAE,KAAK,EAAE;;KAAA;;;;;;;;;;;;IA2Cf,YAAY;IAQlB,eAAe,CAAC,WAAW,EAAE,GAAG,CAAC,MAAM,CAAC;;;;IAWlC,MAAM,CAAC,KAAK,KAAK,EAAE,OAAO,KAAK;;;;;;;IAmCrC;;;OAGG;IACG,YAAY,CAAC,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,aAAa,EAAE,MAAM,OAAO,CAAC,OAAO,CAAC;IAoCzF,IAAI,iBAAiB,QAEpB;IAED,IAAI,GAAG,WAWN;CACF"}
|
|
@@ -200,7 +200,7 @@ export default class NetlifyFunction {
|
|
|
200
200
|
await this.buildQueue;
|
|
201
201
|
let path = rawPath !== '/' && rawPath.endsWith('/') ? rawPath.slice(0, -1) : rawPath;
|
|
202
202
|
path = path.toLowerCase();
|
|
203
|
-
const { routes = [] } = this.buildData;
|
|
203
|
+
const { routes = [] } = this.buildData ?? {};
|
|
204
204
|
// @ts-expect-error TS(7031) FIXME: Binding element 'expression' implicitly has an 'an... Remove this comment to see the full error message
|
|
205
205
|
const route = routes.find(({ expression, literal, methods }) => {
|
|
206
206
|
if (methods.length !== 0 && !methods.includes(method)) {
|
|
@@ -212,7 +212,7 @@ export class FunctionsRegistry {
|
|
|
212
212
|
if (!func) {
|
|
213
213
|
return { func: null, route: null };
|
|
214
214
|
}
|
|
215
|
-
const { routes = [] } = await func.getBuildData();
|
|
215
|
+
const { routes = [] } = (await func.getBuildData()) ?? {};
|
|
216
216
|
if (routes.length !== 0) {
|
|
217
217
|
// @ts-expect-error TS(7006) FIXME: Parameter 'route' implicitly has an 'any' type.
|
|
218
218
|
const paths = routes.map((route) => chalk.underline(route.pattern)).join(', ');
|
|
@@ -1,20 +1,31 @@
|
|
|
1
|
+
import { type RequestHandler } from 'express';
|
|
2
|
+
import type BaseCommand from '../../commands/base-command.js';
|
|
3
|
+
import type { $TSFixMe } from '../../commands/types.js';
|
|
4
|
+
import type { BlobsContext } from '../blobs/blobs.js';
|
|
1
5
|
import { FunctionsRegistry } from './registry.js';
|
|
2
|
-
export declare const createHandler: (options:
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
6
|
+
export declare const createHandler: (options: GetFunctionsServerOptions) => RequestHandler;
|
|
7
|
+
interface GetFunctionsServerOptions {
|
|
8
|
+
functionsRegistry: FunctionsRegistry;
|
|
9
|
+
siteUrl: string;
|
|
10
|
+
siteInfo?: $TSFixMe;
|
|
11
|
+
accountId: string;
|
|
12
|
+
geoCountry: string;
|
|
13
|
+
offline: boolean;
|
|
14
|
+
state: $TSFixMe;
|
|
15
|
+
config: $TSFixMe;
|
|
16
|
+
geolocationMode: 'cache' | 'update' | 'mock';
|
|
17
|
+
}
|
|
18
|
+
export declare const startFunctionsServer: (options: {
|
|
19
|
+
blobsContext: BlobsContext;
|
|
20
|
+
command: BaseCommand;
|
|
21
|
+
config: $TSFixMe;
|
|
22
|
+
capabilities: $TSFixMe;
|
|
23
|
+
debug: boolean;
|
|
24
|
+
loadDistFunctions?: boolean;
|
|
25
|
+
settings: $TSFixMe;
|
|
26
|
+
site: $TSFixMe;
|
|
27
|
+
siteInfo: $TSFixMe;
|
|
28
|
+
timeouts: $TSFixMe;
|
|
29
|
+
} & Omit<GetFunctionsServerOptions, 'functionsRegistry'>) => Promise<FunctionsRegistry | undefined>;
|
|
30
|
+
export {};
|
|
20
31
|
//# sourceMappingURL=server.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../../../src/lib/functions/server.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../../../src/lib/functions/server.ts"],"names":[],"mappings":"AAIA,OAAgB,EAAE,KAAK,cAAc,EAAE,MAAM,SAAS,CAAA;AAKtD,OAAO,KAAK,WAAW,MAAM,gCAAgC,CAAA;AAC7D,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,yBAAyB,CAAA;AAUvD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAA;AAMrD,OAAO,EAAE,iBAAiB,EAAE,MAAM,eAAe,CAAA;AAyDjD,eAAO,MAAM,aAAa,YAAsB,yBAAyB,KAAG,cA8J3E,CAAA;AAED,UAAU,yBAAyB;IACjC,iBAAiB,EAAE,iBAAiB,CAAA;IACpC,OAAO,EAAE,MAAM,CAAA;IACf,QAAQ,CAAC,EAAE,QAAQ,CAAA;IACnB,SAAS,EAAE,MAAM,CAAA;IACjB,UAAU,EAAE,MAAM,CAAA;IAClB,OAAO,EAAE,OAAO,CAAA;IAChB,KAAK,EAAE,QAAQ,CAAA;IACf,MAAM,EAAE,QAAQ,CAAA;IAChB,eAAe,EAAE,OAAO,GAAG,QAAQ,GAAG,MAAM,CAAA;CAC7C;AA4BD,eAAO,MAAM,oBAAoB,YACtB;IACP,YAAY,EAAE,YAAY,CAAA;IAC1B,OAAO,EAAE,WAAW,CAAA;IACpB,MAAM,EAAE,QAAQ,CAAA;IAChB,YAAY,EAAE,QAAQ,CAAA;IACtB,KAAK,EAAE,OAAO,CAAA;IACd,iBAAiB,CAAC,EAAE,OAAO,CAAA;IAC3B,QAAQ,EAAE,QAAQ,CAAA;IAClB,IAAI,EAAE,QAAQ,CAAA;IACd,QAAQ,EAAE,QAAQ,CAAA;IAClB,QAAQ,EAAE,QAAQ,CAAA;CACnB,GAAG,KAAK,yBAAyB,EAAE,mBAAmB,CAAC,KACvD,QAAQ,iBAAiB,GAAG,SAAS,CAiFvC,CAAA"}
|
|
@@ -64,10 +64,8 @@ const hasBody = (req) =>
|
|
|
64
64
|
(req.header('transfer-encoding') !== undefined || !isNaN(req.header('content-length'))) &&
|
|
65
65
|
// we expect a string or a buffer, because we use the two bodyParsers(text, raw) from express
|
|
66
66
|
(typeof req.body === 'string' || Buffer.isBuffer(req.body));
|
|
67
|
-
// @ts-expect-error TS(7006) FIXME: Parameter 'options' implicitly has an 'any' type.
|
|
68
67
|
export const createHandler = function (options) {
|
|
69
68
|
const { functionsRegistry } = options;
|
|
70
|
-
// @ts-expect-error TS(7006) FIXME: Parameter 'request' implicitly has an 'any' type.
|
|
71
69
|
return async function handler(request, response) {
|
|
72
70
|
// If these headers are set, it means we've already matched a function and we
|
|
73
71
|
// can just grab its name directly. We delete the header from the request
|
|
@@ -76,13 +74,18 @@ export const createHandler = function (options) {
|
|
|
76
74
|
delete request.headers[NFFunctionName];
|
|
77
75
|
const functionRoute = request.header(NFFunctionRoute);
|
|
78
76
|
delete request.headers[NFFunctionRoute];
|
|
79
|
-
// If
|
|
80
|
-
//
|
|
77
|
+
// If there's still no function found, we check the functionsRegistry again.
|
|
78
|
+
// This is needed for the functions:serve command, where the dev server that normally does the matching doesn't run.
|
|
79
|
+
// It also matches the default URL (.netlify/functions/builders)
|
|
81
80
|
if (!functionName) {
|
|
82
|
-
const
|
|
83
|
-
|
|
81
|
+
const match = await functionsRegistry.getFunctionForURLPath(request.url, request.method,
|
|
82
|
+
// we're pretending there's no static file at the same URL.
|
|
83
|
+
// This is wrong, but in local dev we already did the matching
|
|
84
|
+
// in a downstream server where we had access to the file system, so this never hits.
|
|
85
|
+
() => Promise.resolve(false));
|
|
86
|
+
functionName = match?.func?.name;
|
|
84
87
|
}
|
|
85
|
-
const func = functionsRegistry.get(functionName);
|
|
88
|
+
const func = functionsRegistry.get(functionName ?? '');
|
|
86
89
|
if (func === undefined) {
|
|
87
90
|
response.statusCode = 404;
|
|
88
91
|
response.end('Function not found...');
|
|
@@ -99,15 +102,13 @@ export const createHandler = function (options) {
|
|
|
99
102
|
body = request.body.toString(isBase64Encoded ? 'base64' : 'utf8');
|
|
100
103
|
}
|
|
101
104
|
let remoteAddress = request.header('x-forwarded-for') || request.connection.remoteAddress || '';
|
|
102
|
-
remoteAddress =
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
delete request.headers['x-netlify-original-pathname'];
|
|
110
|
-
}
|
|
105
|
+
remoteAddress =
|
|
106
|
+
remoteAddress
|
|
107
|
+
.split(remoteAddress.includes('.') ? ':' : ',')
|
|
108
|
+
.pop()
|
|
109
|
+
?.trim() ?? '';
|
|
110
|
+
const requestPath = request.header('x-netlify-original-pathname') ?? request.path;
|
|
111
|
+
delete request.headers['x-netlify-original-pathname'];
|
|
111
112
|
let requestQuery = request.query;
|
|
112
113
|
if (request.header('x-netlify-original-search')) {
|
|
113
114
|
const newRequestQuery = {};
|
|
@@ -120,7 +121,7 @@ export const createHandler = function (options) {
|
|
|
120
121
|
delete request.headers['x-netlify-original-search'];
|
|
121
122
|
}
|
|
122
123
|
const queryParams = Object.entries(requestQuery).reduce((prev, [key, value]) => ({ ...prev, [key]: Array.isArray(value) ? value : [value] }), {});
|
|
123
|
-
const geoLocation = await getGeoLocation({ ...options, mode: options.
|
|
124
|
+
const geoLocation = await getGeoLocation({ ...options, mode: options.geolocationMode });
|
|
124
125
|
const headers = Object.entries({
|
|
125
126
|
...request.headers,
|
|
126
127
|
'client-ip': [remoteAddress],
|
|
@@ -191,9 +192,8 @@ export const createHandler = function (options) {
|
|
|
191
192
|
}
|
|
192
193
|
};
|
|
193
194
|
};
|
|
194
|
-
// @ts-expect-error TS(7006) FIXME: Parameter 'options' implicitly has an 'any' type.
|
|
195
195
|
const getFunctionsServer = (options) => {
|
|
196
|
-
const {
|
|
196
|
+
const { functionsRegistry, siteUrl } = options;
|
|
197
197
|
const app = express();
|
|
198
198
|
const functionHandler = createHandler(options);
|
|
199
199
|
app.set('query parser', 'simple');
|
|
@@ -206,27 +206,9 @@ const getFunctionsServer = (options) => {
|
|
|
206
206
|
app.use(expressLogging(console, {
|
|
207
207
|
blacklist: ['/favicon.ico'],
|
|
208
208
|
}));
|
|
209
|
-
app.all(
|
|
210
|
-
app.all(`${buildersPrefix}*`, functionHandler);
|
|
209
|
+
app.all('*', functionHandler);
|
|
211
210
|
return app;
|
|
212
211
|
};
|
|
213
|
-
/**
|
|
214
|
-
*
|
|
215
|
-
* @param {object} options
|
|
216
|
-
* @param {import("../blobs/blobs.js").BlobsContext} options.blobsContext
|
|
217
|
-
* @param {import('../../commands/base-command.js').default} options.command
|
|
218
|
-
* @param {*} options.capabilities
|
|
219
|
-
* @param {*} options.config
|
|
220
|
-
* @param {boolean} options.debug
|
|
221
|
-
* @param {*} options.loadDistFunctions
|
|
222
|
-
* @param {*} options.settings
|
|
223
|
-
* @param {*} options.site
|
|
224
|
-
* @param {*} options.siteInfo
|
|
225
|
-
* @param {string} options.siteUrl
|
|
226
|
-
* @param {*} options.timeouts
|
|
227
|
-
* @returns {Promise<import('./registry.js').FunctionsRegistry | undefined>}
|
|
228
|
-
*/
|
|
229
|
-
// @ts-expect-error TS(7006) FIXME: Parameter 'options' implicitly has an 'any' type.
|
|
230
212
|
export const startFunctionsServer = async (options) => {
|
|
231
213
|
const { blobsContext, capabilities, command, config, debug, loadDistFunctions, settings, site, siteInfo, siteUrl, timeouts, } = options;
|
|
232
214
|
const internalFunctionsDir = await getInternalFunctionsDir({ base: site.root });
|
|
@@ -283,29 +265,20 @@ export const startFunctionsServer = async (options) => {
|
|
|
283
265
|
timeouts,
|
|
284
266
|
});
|
|
285
267
|
await functionsRegistry.scan(functionsDirectories);
|
|
286
|
-
const server = getFunctionsServer(
|
|
268
|
+
const server = getFunctionsServer({ ...options, functionsRegistry });
|
|
287
269
|
await startWebServer({ server, settings, debug });
|
|
288
270
|
return functionsRegistry;
|
|
289
271
|
};
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
* @param {object} config
|
|
293
|
-
* @param {boolean} config.debug
|
|
294
|
-
* @param {ReturnType<Awaited<typeof getFunctionsServer>>} config.server
|
|
295
|
-
* @param {*} config.settings
|
|
296
|
-
*/
|
|
297
|
-
// @ts-expect-error TS(7031) FIXME: Binding element 'debug' implicitly has an 'any' ty... Remove this comment to see the full error message
|
|
298
|
-
const startWebServer = async ({ debug, server, settings }) => {
|
|
299
|
-
await new Promise((/** @type {(resolve: void) => void} */ resolve) => {
|
|
272
|
+
const startWebServer = async ({ debug, server, settings, }) => {
|
|
273
|
+
await new Promise((resolve) => {
|
|
300
274
|
// @ts-expect-error TS(7006) FIXME: Parameter 'err' implicitly has an 'any' type.
|
|
301
|
-
server.listen(settings.functionsPort, (
|
|
275
|
+
server.listen(settings.functionsPort, (err) => {
|
|
302
276
|
if (err) {
|
|
303
277
|
errorExit(`${NETLIFYDEVERR} Unable to start functions server: ${err}`);
|
|
304
278
|
}
|
|
305
279
|
else if (debug) {
|
|
306
280
|
log(`${NETLIFYDEVLOG} Functions server is listening on ${settings.functionsPort}`);
|
|
307
281
|
}
|
|
308
|
-
// @ts-expect-error TS(2794) FIXME: Expected 1 arguments, but got 0. Did you forget to... Remove this comment to see the full error message
|
|
309
282
|
resolve();
|
|
310
283
|
});
|
|
311
284
|
});
|