@vectorx/functions-framework 0.0.0-beta-20251112071234

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.
Files changed (71) hide show
  1. package/README.md +141 -0
  2. package/bin/rcb-ff.js +153 -0
  3. package/lib/async-context.js +61 -0
  4. package/lib/config.js +10 -0
  5. package/lib/constants.js +10 -0
  6. package/lib/error.js +47 -0
  7. package/lib/framework.js +183 -0
  8. package/lib/function-loader.js +63 -0
  9. package/lib/function-registry.js +20 -0
  10. package/lib/function-wrapper.js +170 -0
  11. package/lib/index.js +23 -0
  12. package/lib/logger.js +204 -0
  13. package/lib/middlewares/index.js +19 -0
  14. package/lib/middlewares/middle-apm-injection.js +37 -0
  15. package/lib/middlewares/middle-async-context.js +27 -0
  16. package/lib/middlewares/middle-common-logger.js +67 -0
  17. package/lib/middlewares/middle-context-injection.js +33 -0
  18. package/lib/middlewares/middle-event-id.js +20 -0
  19. package/lib/middlewares/middle-function-route.js +26 -0
  20. package/lib/middlewares/middle-logs-request.js +98 -0
  21. package/lib/middlewares/middle-open-gw-request.js +29 -0
  22. package/lib/request.js +162 -0
  23. package/lib/router.js +51 -0
  24. package/lib/server.js +115 -0
  25. package/lib/sse.js +258 -0
  26. package/lib/telemetry/langfuse.js +13 -0
  27. package/lib/types.js +2 -0
  28. package/lib/unified-responder.js +64 -0
  29. package/lib/user-logger.js +54 -0
  30. package/lib/utils/apm.config.js +7 -0
  31. package/lib/utils/apm.js +140 -0
  32. package/lib/utils/common.js +5 -0
  33. package/lib/utils/console-intercept.js +58 -0
  34. package/lib/utils/error-stack.js +30 -0
  35. package/lib/utils/helper.js +88 -0
  36. package/lib/utils/machineId.js +72 -0
  37. package/package.json +76 -0
  38. package/types/async-context.d.ts +17 -0
  39. package/types/config.d.ts +1 -0
  40. package/types/constants.d.ts +2 -0
  41. package/types/error.d.ts +20 -0
  42. package/types/framework.d.ts +32 -0
  43. package/types/function-loader.d.ts +26 -0
  44. package/types/function-registry.d.ts +4 -0
  45. package/types/function-wrapper.d.ts +3 -0
  46. package/types/index.d.ts +7 -0
  47. package/types/logger.d.ts +74 -0
  48. package/types/middlewares/index.d.ts +8 -0
  49. package/types/middlewares/middle-apm-injection.d.ts +2 -0
  50. package/types/middlewares/middle-async-context.d.ts +2 -0
  51. package/types/middlewares/middle-common-logger.d.ts +2 -0
  52. package/types/middlewares/middle-context-injection.d.ts +4 -0
  53. package/types/middlewares/middle-event-id.d.ts +2 -0
  54. package/types/middlewares/middle-function-route.d.ts +4 -0
  55. package/types/middlewares/middle-logs-request.d.ts +3 -0
  56. package/types/middlewares/middle-open-gw-request.d.ts +2 -0
  57. package/types/request.d.ts +46 -0
  58. package/types/router.d.ts +15 -0
  59. package/types/server.d.ts +33 -0
  60. package/types/sse.d.ts +23 -0
  61. package/types/telemetry/langfuse.d.ts +4 -0
  62. package/types/types.d.ts +18 -0
  63. package/types/unified-responder.d.ts +15 -0
  64. package/types/user-logger.d.ts +5 -0
  65. package/types/utils/apm.config.d.ts +6 -0
  66. package/types/utils/apm.d.ts +21 -0
  67. package/types/utils/common.d.ts +2 -0
  68. package/types/utils/console-intercept.d.ts +6 -0
  69. package/types/utils/error-stack.d.ts +5 -0
  70. package/types/utils/helper.d.ts +7 -0
  71. package/types/utils/machineId.d.ts +2 -0
@@ -0,0 +1,98 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.logsQueryMiddleware = logsQueryMiddleware;
13
+ const logger_1 = require("../logger");
14
+ const logger_2 = require("../logger");
15
+ function logsQueryMiddleware() {
16
+ return (ctx, next) => __awaiter(this, void 0, void 0, function* () {
17
+ if (ctx.path.startsWith("/@logs")) {
18
+ const type = ctx.query.type || logger_1.LogType.ACCESS;
19
+ const pageNumParam = ctx.query.pageNum;
20
+ const pageSizeParam = ctx.query.pageSize;
21
+ const limitParam = ctx.query.limit;
22
+ if (pageNumParam !== undefined || pageSizeParam !== undefined) {
23
+ const pageNum = pageNumParam ? Number.parseInt(pageNumParam) : 1;
24
+ const pageSize = pageSizeParam ? Number.parseInt(pageSizeParam) : 50;
25
+ if (Number.isNaN(pageNum) || pageNum <= 0) {
26
+ ctx.status = 400;
27
+ ctx.body = {
28
+ success: false,
29
+ error: "Invalid pageNum parameter. Must be a positive number.",
30
+ };
31
+ return;
32
+ }
33
+ if (Number.isNaN(pageSize) || pageSize <= 0 || pageSize > 100) {
34
+ ctx.status = 400;
35
+ ctx.body = {
36
+ success: false,
37
+ error: "Invalid pageSize parameter. Must be a positive number <= 100",
38
+ };
39
+ return;
40
+ }
41
+ try {
42
+ const result = yield logger_2.functionsLogger.getLogsPaginated({
43
+ type,
44
+ pageNum,
45
+ pageSize,
46
+ });
47
+ ctx.body = {
48
+ success: true,
49
+ data: result.logs,
50
+ pagination: {
51
+ pageNum: result.pageNum,
52
+ pageSize: result.pageSize,
53
+ total: result.total,
54
+ hasMore: result.hasMore,
55
+ },
56
+ };
57
+ }
58
+ catch (error) {
59
+ logger_2.functionsLogger.logError(error);
60
+ ctx.status = 500;
61
+ ctx.body = {
62
+ success: false,
63
+ error: error.message,
64
+ };
65
+ }
66
+ return;
67
+ }
68
+ else {
69
+ const limit = limitParam ? Number.parseInt(limitParam) : 100;
70
+ if (Number.isNaN(limit) || limit <= 0 || limit > 1000) {
71
+ ctx.status = 400;
72
+ ctx.body = {
73
+ success: false,
74
+ error: "Invalid limit parameter. Must be a positive number <= 1000",
75
+ };
76
+ return;
77
+ }
78
+ try {
79
+ const logs = yield logger_2.functionsLogger.getLogs(type, limit);
80
+ ctx.body = {
81
+ success: true,
82
+ data: logs,
83
+ };
84
+ }
85
+ catch (error) {
86
+ logger_2.functionsLogger.logError(error);
87
+ ctx.status = 500;
88
+ ctx.body = {
89
+ success: false,
90
+ error: error.message,
91
+ };
92
+ }
93
+ return;
94
+ }
95
+ }
96
+ return yield next();
97
+ });
98
+ }
@@ -0,0 +1,29 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.openGwRequestMiddleware = openGwRequestMiddleware;
13
+ const error_1 = require("../error");
14
+ const unified_responder_1 = require("../unified-responder");
15
+ function openGwRequestMiddleware(agentId) {
16
+ return (ctx, next) => __awaiter(this, void 0, void 0, function* () {
17
+ if (process.env.OPEN_PLATFORM_STAGE === "production") {
18
+ const openId = ctx.headers["open-id"];
19
+ if (!openId) {
20
+ return (0, unified_responder_1.sendResponse)(ctx, undefined, (0, error_1.newBadRequestErr)("open-id is required"), 401);
21
+ }
22
+ const requestAgentId = ctx.headers["agent-id"];
23
+ if (requestAgentId !== agentId) {
24
+ return (0, unified_responder_1.sendResponse)(ctx, undefined, (0, error_1.newBadRequestErr)("unauthorized, agent-id mismatch!"), 401);
25
+ }
26
+ }
27
+ yield next();
28
+ });
29
+ }
package/lib/request.js ADDED
@@ -0,0 +1,162 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ var __importDefault = (this && this.__importDefault) || function (mod) {
12
+ return (mod && mod.__esModule) ? mod : { "default": mod };
13
+ };
14
+ Object.defineProperty(exports, "__esModule", { value: true });
15
+ exports.Request = void 0;
16
+ const stream_1 = require("stream");
17
+ const node_fetch_1 = __importDefault(require("node-fetch"));
18
+ const helper_1 = require("./utils/helper");
19
+ function headersInit2Indexable(h) {
20
+ if (isHeaders(h)) {
21
+ const ret = {};
22
+ h.forEach((val, key) => {
23
+ ret[key] = val;
24
+ });
25
+ return ret;
26
+ }
27
+ return h;
28
+ function isHeaders(h) {
29
+ return h instanceof Headers;
30
+ }
31
+ }
32
+ class Request {
33
+ constructor(config = {}) {
34
+ const { timeout, timeoutMsg, restrictedMethods, defaultHeaders = {} } = config;
35
+ this.defaultHeaders = defaultHeaders;
36
+ this.timeout = timeout || 0;
37
+ this.timeoutMsg = timeoutMsg || "请求超时";
38
+ this.restrictedMethods = restrictedMethods || ["get", "post", "upload", "download"];
39
+ }
40
+ get(options) {
41
+ return this.request(Object.assign(Object.assign({}, options), { method: "get" }), this.restrictedMethods.includes("get"));
42
+ }
43
+ post(options) {
44
+ return this.request(Object.assign(Object.assign({}, options), { method: "post" }), this.restrictedMethods.includes("post"));
45
+ }
46
+ put(options) {
47
+ return this.request(Object.assign(Object.assign({}, options), { method: "put" }));
48
+ }
49
+ upload(options) {
50
+ var _a;
51
+ const { data: _data, file, name, method, headers = {} } = options;
52
+ if (file === undefined || name === undefined) {
53
+ throw new Error("file and name is required");
54
+ }
55
+ const data = (0, helper_1.obj2StrRecord)(_data !== null && _data !== void 0 ? _data : {});
56
+ const loweredMethod = method === null || method === void 0 ? void 0 : method.toLowerCase();
57
+ const reqMethod = (_a = ["post", "put"].find((m) => m === loweredMethod)) !== null && _a !== void 0 ? _a : "put";
58
+ if (reqMethod === "post") {
59
+ const formData = new FormData();
60
+ Object.keys(data).forEach((key) => {
61
+ formData.append(key, data[key]);
62
+ });
63
+ formData.append("key", name);
64
+ formData.append("file", file);
65
+ return this.request(Object.assign(Object.assign({}, options), { data: formData, method: reqMethod }), this.restrictedMethods.includes("upload"));
66
+ }
67
+ return this.request(Object.assign(Object.assign({}, options), { method: "put", headers, body: file }), this.restrictedMethods.includes("upload"));
68
+ }
69
+ download(options) {
70
+ return __awaiter(this, void 0, void 0, function* () {
71
+ const { data } = yield this.get(Object.assign(Object.assign({}, options), { headers: {}, responseType: "blob" }));
72
+ return {
73
+ statusCode: 200,
74
+ tempFilePath: options.url,
75
+ data,
76
+ };
77
+ });
78
+ }
79
+ request(options_1) {
80
+ return __awaiter(this, arguments, void 0, function* (options, enableAbort = false) {
81
+ const { url, headers: _headers = {}, data, responseType, withCredentials, body, method: _method } = options, headers = Object.assign(Object.assign({}, this.defaultHeaders), (0, helper_1.obj2StrRecord)(_headers)), method = String(_method).toLowerCase() || "get";
82
+ let queryParams = {};
83
+ if (method === "get" || method === "head") {
84
+ queryParams = Object.assign(Object.assign({}, (data || {})), (body && typeof body === "object" ? body : {}));
85
+ }
86
+ else {
87
+ queryParams = method === "get" ? data : {};
88
+ }
89
+ const realUrl = (0, helper_1.formatUrl)("https", url !== null && url !== void 0 ? url : "", queryParams), controller = new AbortController(), { signal } = controller;
90
+ let timer;
91
+ if (enableAbort && this.timeout) {
92
+ timer = setTimeout(() => {
93
+ console.warn(this.timeoutMsg);
94
+ controller.abort(new Error(this.timeoutMsg));
95
+ }, this.timeout);
96
+ }
97
+ let payload;
98
+ if (method !== "get" && method !== "head") {
99
+ if ((0, helper_1.isFormData)(data)) {
100
+ payload = data;
101
+ }
102
+ else if (headers["content-type"] === "application/x-www-form-urlencoded") {
103
+ payload = (0, helper_1.toQueryString)(data !== null && data !== void 0 ? data : {});
104
+ }
105
+ else if (body) {
106
+ payload = body;
107
+ }
108
+ else {
109
+ payload = data ? JSON.stringify(data) : undefined;
110
+ }
111
+ }
112
+ const requestOptions = Object.assign(Object.assign({ method,
113
+ headers }, (payload !== undefined && { body: payload })), { credentials: withCredentials ? "include" : "same-origin", signal });
114
+ try {
115
+ const response = yield (0, node_fetch_1.default)(realUrl, requestOptions), result = {
116
+ header: {},
117
+ statusCode: response.status,
118
+ };
119
+ try {
120
+ result.data = responseType === "blob" ? yield response.blob() : yield response.json();
121
+ }
122
+ catch (_) {
123
+ result.data = responseType === "blob" ? yield response.blob() : yield response.text();
124
+ }
125
+ const { headers } = response;
126
+ headers.forEach((val, key) => (result.header[key.toLowerCase()] = val));
127
+ return result;
128
+ }
129
+ finally {
130
+ clearTimeout(timer);
131
+ }
132
+ });
133
+ }
134
+ fetch(options) {
135
+ return __awaiter(this, void 0, void 0, function* () {
136
+ const { url, enableAbort = false, stream = false } = options, abortController = new AbortController();
137
+ let timer = undefined;
138
+ if (enableAbort && this.timeout) {
139
+ timer = setTimeout(() => {
140
+ console.warn(this.timeoutMsg);
141
+ abortController.abort(new Error(this.timeoutMsg));
142
+ }, this.timeout);
143
+ }
144
+ const res = yield (yield node_fetch_1.default)(url, Object.assign(Object.assign({}, options), { headers: Object.assign(Object.assign({}, this.defaultHeaders), (options.headers ? headersInit2Indexable(options.headers) : {})), body: options.body, signal: abortController.signal }))
145
+ .then((x) => {
146
+ clearTimeout(timer);
147
+ return x;
148
+ })
149
+ .catch((x) => {
150
+ clearTimeout(timer);
151
+ return Promise.reject(x);
152
+ });
153
+ const ret = {
154
+ data: stream ? (res.body ? stream_1.Readable.toWeb(res.body) : res.body) : yield res.json(),
155
+ statusCode: res.status,
156
+ header: res.headers,
157
+ };
158
+ return ret;
159
+ });
160
+ }
161
+ }
162
+ exports.Request = Request;
package/lib/router.js ADDED
@@ -0,0 +1,51 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Router = void 0;
4
+ exports.routeFunction = routeFunction;
5
+ const radix3_1 = require("radix3");
6
+ const function_registry_1 = require("./function-registry");
7
+ class Router {
8
+ constructor(config) {
9
+ this.routes = new Map();
10
+ this.router = (0, radix3_1.createRouter)({
11
+ strictTrailingSlash: false,
12
+ });
13
+ for (const route of config.routes) {
14
+ if (route.path) {
15
+ const p = route.path.endsWith("/") ? route.path : route.path + "/";
16
+ if (this.routes.has(p)) {
17
+ continue;
18
+ }
19
+ this.routes.set(p, route);
20
+ this.routes.set(p + "**", route);
21
+ }
22
+ }
23
+ for (const [path, route] of this.routes.entries()) {
24
+ this.addRoute(path, route);
25
+ }
26
+ }
27
+ addRoute(path, route) {
28
+ this.router.insert(path, route);
29
+ }
30
+ findRoute(path) {
31
+ const found = this.router.lookup(path);
32
+ if (!found) {
33
+ return null;
34
+ }
35
+ if (found.params) {
36
+ delete found.params;
37
+ }
38
+ return found;
39
+ }
40
+ }
41
+ exports.Router = Router;
42
+ function routeFunction(router, path) {
43
+ const matchedRoute = router.findRoute(path);
44
+ if (matchedRoute) {
45
+ return {
46
+ routeDefinition: matchedRoute,
47
+ handleFunction: (0, function_registry_1.getRegisteredFunction)((0, function_registry_1.buildFnId)("@fn", matchedRoute.functionName)),
48
+ };
49
+ }
50
+ return {};
51
+ }
package/lib/server.js ADDED
@@ -0,0 +1,115 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ var __importDefault = (this && this.__importDefault) || function (mod) {
12
+ return (mod && mod.__esModule) ? mod : { "default": mod };
13
+ };
14
+ Object.defineProperty(exports, "__esModule", { value: true });
15
+ exports.createServer = createServer;
16
+ const http_1 = __importDefault(require("http"));
17
+ const koa_1 = __importDefault(require("koa"));
18
+ const koa_body_1 = require("koa-body");
19
+ const error_1 = require("./error");
20
+ const middlewares_1 = require("./middlewares");
21
+ const unified_responder_1 = require("./unified-responder");
22
+ function corsMiddleware() {
23
+ return (ctx, next) => __awaiter(this, void 0, void 0, function* () {
24
+ ctx.set("Access-Control-Allow-Origin", "*");
25
+ ctx.set("Access-Control-Allow-Methods", "GET, POST, PUT, DELETE, OPTIONS");
26
+ ctx.set("Access-Control-Allow-Headers", "Content-Type, Authorization, Accept, X-Requested-With, Referer, referrer");
27
+ ctx.set("Access-Control-Max-Age", "86400");
28
+ if (ctx.method === "OPTIONS") {
29
+ ctx.status = 204;
30
+ return;
31
+ }
32
+ yield next();
33
+ });
34
+ }
35
+ function createServer(options, router, projectConfig) {
36
+ const app = new koa_1.default();
37
+ app.use(corsMiddleware());
38
+ app.use((0, middlewares_1.logsQueryMiddleware)());
39
+ app.use((ctx, next) => __awaiter(this, void 0, void 0, function* () {
40
+ try {
41
+ const h = ctx.request.headers || {};
42
+ console.log("[REQ-IN]", ctx.method, ctx.url, {
43
+ "content-type": h["content-type"],
44
+ "content-length": h["content-length"],
45
+ "transfer-encoding": h["transfer-encoding"],
46
+ });
47
+ }
48
+ catch (e) {
49
+ }
50
+ yield next();
51
+ }));
52
+ app.use((0, middlewares_1.contextInjectionMiddleware)(options, projectConfig));
53
+ app.use((0, middlewares_1.eventIdMiddleware)());
54
+ app.use((0, middlewares_1.apmMiddleware)());
55
+ app.use((0, middlewares_1.asyncContextMiddleware)());
56
+ app.use((0, middlewares_1.loggerMiddleware)());
57
+ app.use((0, koa_body_1.koaBody)({
58
+ multipart: true,
59
+ patchKoa: true,
60
+ formidable: {
61
+ maxFileSize: 50 * 1024 * 1024,
62
+ enabledPlugins: ["octetstream", "json", "multipart"],
63
+ keepExtensions: true,
64
+ filter: ({ originalFilename }) => {
65
+ return !!originalFilename;
66
+ },
67
+ },
68
+ onError: (err, ctx) => {
69
+ var _a;
70
+ try {
71
+ const h = ((_a = ctx.request) === null || _a === void 0 ? void 0 : _a.headers) || {};
72
+ console.error("[koa-body][error]", {
73
+ message: err === null || err === void 0 ? void 0 : err.message,
74
+ name: err === null || err === void 0 ? void 0 : err.name,
75
+ code: err === null || err === void 0 ? void 0 : err.code,
76
+ status: err === null || err === void 0 ? void 0 : err.status,
77
+ headers: {
78
+ "content-type": h["content-type"],
79
+ "content-length": h["content-length"],
80
+ "transfer-encoding": h["transfer-encoding"],
81
+ },
82
+ });
83
+ }
84
+ catch (_) { }
85
+ return (0, unified_responder_1.sendResponse)(ctx, undefined, (0, error_1.newBadRequestErr)(err), 400);
86
+ },
87
+ }));
88
+ app.use((ctx, next) => __awaiter(this, void 0, void 0, function* () {
89
+ var _a, _b;
90
+ try {
91
+ const fields = ((_a = ctx.request) === null || _a === void 0 ? void 0 : _a.body) ? Object.keys(ctx.request.body) : [];
92
+ const files = (_b = ctx.request) === null || _b === void 0 ? void 0 : _b.files;
93
+ console.log("[REQ-PARSED] Body", JSON.stringify(ctx.request.body, null, 2));
94
+ console.log("[REQ-PARSED] files", JSON.stringify(ctx.request.files, null, 2));
95
+ }
96
+ catch (_) { }
97
+ yield next();
98
+ }));
99
+ app.use((ctx, next) => __awaiter(this, void 0, void 0, function* () {
100
+ if (!(ctx.request.files || ctx.request.body || ctx.state.isTimeout)) {
101
+ try {
102
+ console.log("==== ctx.request.files ====", ctx.request.files);
103
+ console.log("==== ctx.request.body ====", ctx.request.body);
104
+ }
105
+ catch (err) {
106
+ return (0, unified_responder_1.sendResponse)(ctx, undefined, (0, error_1.newBadRequestErr)(err), 400);
107
+ }
108
+ }
109
+ yield next();
110
+ }));
111
+ app.use((0, middlewares_1.openGwRequestMiddleware)(projectConfig.agentId));
112
+ app.use((0, middlewares_1.functionRouteMiddleware)(router, projectConfig));
113
+ const httpServer = http_1.default.createServer(app.callback());
114
+ return httpServer;
115
+ }