@centeredgesoft/runtime-mock-routes 2.1.0 → 2.5.0

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.
@@ -1,177 +1,196 @@
1
- "use strict";
2
- var __rest = (this && this.__rest) || function (s, e) {
3
- var t = {};
4
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
5
- t[p] = s[p];
6
- if (s != null && typeof Object.getOwnPropertySymbols === "function")
7
- for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
8
- if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
9
- t[p[i]] = s[p[i]];
10
- }
11
- return t;
12
- };
13
- var __importDefault = (this && this.__importDefault) || function (mod) {
14
- return (mod && mod.__esModule) ? mod : { "default": mod };
15
- };
16
- Object.defineProperty(exports, "__esModule", { value: true });
17
- exports.appFactory = exports.isRuntimeRequestCollection = exports.isRuntimeRequestBody = exports.isRuntimeRequestMethodBodyCollection = exports.isRuntimeRequestMethodBody = exports.isSupportedMethod = exports.SupportedMethodsColection = void 0;
18
- const body_parser_1 = __importDefault(require("body-parser"));
19
- const chance_1 = __importDefault(require("chance"));
20
- const cors_1 = __importDefault(require("cors"));
21
- const express_1 = __importDefault(require("express"));
22
- const faker_1 = __importDefault(require("faker"));
23
- const feather_route_matcher_1 = __importDefault(require("feather-route-matcher"));
24
- const handlebars_1 = __importDefault(require("handlebars"));
25
- const lodash_1 = require("lodash");
26
- const sort_keys_1 = __importDefault(require("sort-keys"));
27
- const chance = new chance_1.default();
28
- handlebars_1.default.registerHelper('faker', (funcName, ...rest) => {
29
- try {
30
- const func = lodash_1.get(faker_1.default, funcName, () => '');
31
- return func(...rest);
32
- }
33
- catch (err) {
34
- return err;
35
- }
36
- });
37
- handlebars_1.default.registerHelper('chance', (funcName, ...rest) => {
38
- try {
39
- const func = lodash_1.get(chance, funcName, () => '');
40
- return func.call(chance, ...rest);
41
- }
42
- catch (err) {
43
- return err;
44
- }
45
- });
46
- exports.SupportedMethodsColection = ['GET', 'POST', 'PUT', 'PATCH', 'DELETE'];
47
- exports.isSupportedMethod = (obj) => exports.SupportedMethodsColection.includes(obj);
48
- exports.isRuntimeRequestMethodBody = (obj) => {
49
- try {
50
- return !!obj.body && (!obj.status || !isNaN(Number(obj.status)));
51
- }
52
- catch (_) {
53
- return false;
54
- }
55
- };
56
- exports.isRuntimeRequestMethodBodyCollection = (obj) => {
57
- try {
58
- return !Object.keys(obj).some(k => !(exports.isSupportedMethod(k) && exports.isRuntimeRequestMethodBody(obj[k])));
59
- }
60
- catch (_) {
61
- return false;
62
- }
63
- };
64
- exports.isRuntimeRequestBody = (obj) => {
65
- try {
66
- return typeof obj.path === 'string'
67
- && exports.isRuntimeRequestMethodBodyCollection(obj.methods);
68
- }
69
- catch (_) {
70
- return false;
71
- }
72
- };
73
- exports.isRuntimeRequestCollection = (obj) => {
74
- try {
75
- return !Object.keys(obj).some(k => !exports.isRuntimeRequestBody(obj[k]));
76
- }
77
- catch (_) {
78
- return false;
79
- }
80
- };
81
- exports.appFactory = (runtimeCollection) => {
82
- let runtimeRequestCollection = runtimeCollection || {};
83
- if (!exports.isRuntimeRequestCollection(runtimeRequestCollection)) {
84
- throw new Error('Intial requests JSON is invalid');
85
- }
86
- runtimeRequestCollection = Object.keys(runtimeRequestCollection).reduce((acc, curr) => {
87
- const fixedPath = `/${curr}`.replace(/\/\//g, '/');
88
- const body = Object.assign(Object.assign({}, runtimeCollection[curr]), { path: fixedPath });
89
- return Object.assign(Object.assign({}, acc), { [fixedPath]: body });
90
- }, {});
91
- const app = express_1.default();
92
- app.use(cors_1.default());
93
- app.use(body_parser_1.default.json());
94
- app.get('/', (_req, res) => res.send(sort_keys_1.default(runtimeRequestCollection, { deep: true })));
95
- app.post('/', (req, res) => {
96
- const { body } = req;
97
- if (exports.isRuntimeRequestBody(body)) {
98
- const fixedPath = `/${body.path}`.replace(/\/\//g, '/');
99
- body.path = fixedPath;
100
- runtimeRequestCollection = Object.assign(Object.assign({}, runtimeRequestCollection), { [fixedPath]: body });
101
- return res.status(204).send();
102
- }
103
- return res.status(400).send();
104
- });
105
- app.put('/', (req, res) => {
106
- const { body } = req;
107
- if (!exports.isRuntimeRequestCollection(body)) {
108
- return res.status(400).send('BAD_REQUEST_BODY');
109
- }
110
- const cleanBody = Object.keys(body).reduce((acc, curr) => {
111
- const fixedPath = `/${curr}`.replace(/\/\//g, '/');
112
- const newBody = Object.assign(Object.assign({}, body[curr]), { path: fixedPath });
113
- return Object.assign(Object.assign({}, acc), { [fixedPath]: newBody });
114
- }, {});
115
- runtimeRequestCollection = cleanBody;
116
- return res.status(204).send();
117
- });
118
- app.delete('/', (req, res) => {
119
- let { path } = req.query;
120
- if (!path) {
121
- return res.status(400).send();
122
- }
123
- const cleanPath = Array.isArray(path) ? path.map(p => `${p}`) : [`${path}`];
124
- runtimeRequestCollection = cleanPath.reduce((acc, curr) => {
125
- const _a = acc, _b = curr, _ = _a[_b], rest = __rest(_a, [typeof _b === "symbol" ? _b : _b + ""]);
126
- return rest;
127
- }, runtimeRequestCollection);
128
- return res.status(204).send();
129
- });
130
- const catchAllHandler = (req, res) => {
131
- const matcher = feather_route_matcher_1.default(runtimeRequestCollection);
132
- const routeMatch = matcher(req.path);
133
- if (routeMatch) {
134
- const reqInfo = routeMatch.value;
135
- const params = routeMatch.params;
136
- const method = reqInfo.methods[req.method];
137
- if (!method) {
138
- return res.status(404).send();
139
- }
140
- const tokenParams = {
141
- query: req.query,
142
- params,
143
- body: req.body
144
- };
145
- if (method.status) {
146
- res.status(method.status);
147
- }
148
- const { body } = method;
149
- if (typeof body !== 'string') {
150
- return res.send(body);
151
- }
152
- const template = handlebars_1.default.compile(body);
153
- const result = template(tokenParams);
154
- try {
155
- const jsonResult = JSON.parse(result);
156
- return res.send(jsonResult);
157
- }
158
- catch (_) {
159
- return res.send(result);
160
- }
161
- }
162
- return res.status(404).send();
163
- };
164
- app.get('/*', catchAllHandler);
165
- app.post('/*', catchAllHandler);
166
- app.put('/*', catchAllHandler);
167
- app.patch('/*', catchAllHandler);
168
- app.delete('/*', catchAllHandler);
169
- Object.defineProperty(app, 'runtimeRequestCollection', {
170
- get: () => {
171
- return lodash_1.cloneDeep(runtimeRequestCollection);
172
- }
173
- });
174
- return app;
175
- };
176
- const app = exports.appFactory();
177
- exports.default = app;
1
+ "use strict";
2
+ var __rest = (this && this.__rest) || function (s, e) {
3
+ var t = {};
4
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
5
+ t[p] = s[p];
6
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
7
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
8
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
9
+ t[p[i]] = s[p[i]];
10
+ }
11
+ return t;
12
+ };
13
+ var __importDefault = (this && this.__importDefault) || function (mod) {
14
+ return (mod && mod.__esModule) ? mod : { "default": mod };
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ exports.appFactory = exports.isRuntimeRequestCollection = exports.isRuntimeRequestBody = exports.isRuntimeRequestMethodBodyCollection = exports.isRuntimeRequestMethodBody = exports.isSupportedMethod = exports.SupportedMethodsColection = void 0;
18
+ const chance_1 = __importDefault(require("chance"));
19
+ const cors_1 = __importDefault(require("cors"));
20
+ const express_1 = __importDefault(require("express"));
21
+ const faker_1 = __importDefault(require("faker"));
22
+ const feather_route_matcher_1 = __importDefault(require("feather-route-matcher"));
23
+ const handlebars_1 = __importDefault(require("handlebars"));
24
+ const lodash_1 = require("lodash");
25
+ const sort_keys_1 = __importDefault(require("sort-keys"));
26
+ const chance = new chance_1.default();
27
+ handlebars_1.default.registerHelper('faker', (funcName, ...rest) => {
28
+ try {
29
+ const func = lodash_1.get(faker_1.default, funcName, () => '');
30
+ return func(...rest);
31
+ }
32
+ catch (err) {
33
+ return err;
34
+ }
35
+ });
36
+ handlebars_1.default.registerHelper('chance', (funcName, ...rest) => {
37
+ try {
38
+ const func = lodash_1.get(chance, funcName, () => '');
39
+ return func.call(chance, ...rest);
40
+ }
41
+ catch (err) {
42
+ return err;
43
+ }
44
+ });
45
+ exports.SupportedMethodsColection = ['GET', 'POST', 'PUT', 'PATCH', 'DELETE'];
46
+ const isSupportedMethod = (obj) => exports.SupportedMethodsColection.includes(obj);
47
+ exports.isSupportedMethod = isSupportedMethod;
48
+ const isRuntimeRequestMethodBody = (obj) => {
49
+ try {
50
+ return !!obj.body && (!obj.status || !isNaN(Number(obj.status)));
51
+ }
52
+ catch (_) {
53
+ return false;
54
+ }
55
+ };
56
+ exports.isRuntimeRequestMethodBody = isRuntimeRequestMethodBody;
57
+ const isRuntimeRequestMethodBodyCollection = (obj) => {
58
+ try {
59
+ return !Object.keys(obj).some(k => !(exports.isSupportedMethod(k) && exports.isRuntimeRequestMethodBody(obj[k])));
60
+ }
61
+ catch (_) {
62
+ return false;
63
+ }
64
+ };
65
+ exports.isRuntimeRequestMethodBodyCollection = isRuntimeRequestMethodBodyCollection;
66
+ const isRuntimeRequestBody = (obj) => {
67
+ try {
68
+ return typeof obj.path === 'string'
69
+ && exports.isRuntimeRequestMethodBodyCollection(obj.methods);
70
+ }
71
+ catch (_) {
72
+ return false;
73
+ }
74
+ };
75
+ exports.isRuntimeRequestBody = isRuntimeRequestBody;
76
+ const isRuntimeRequestCollection = (obj) => {
77
+ try {
78
+ return !Object.keys(obj).some(k => !exports.isRuntimeRequestBody(obj[k]));
79
+ }
80
+ catch (_) {
81
+ return false;
82
+ }
83
+ };
84
+ exports.isRuntimeRequestCollection = isRuntimeRequestCollection;
85
+ const appFactory = (runtimeCollection) => {
86
+ let runtimeRequestCollection = runtimeCollection || {};
87
+ if (!exports.isRuntimeRequestCollection(runtimeRequestCollection)) {
88
+ throw new Error('Intial requests JSON is invalid');
89
+ }
90
+ runtimeRequestCollection = Object.keys(runtimeRequestCollection).reduce((acc, curr) => {
91
+ const fixedPath = `/${curr}`.replace(/\/\//g, '/');
92
+ const body = Object.assign(Object.assign({}, runtimeCollection[curr]), { path: fixedPath });
93
+ return Object.assign(Object.assign({}, acc), { [fixedPath]: body });
94
+ }, {});
95
+ const app = express_1.default();
96
+ app.use(cors_1.default());
97
+ app.use(express_1.default.json({
98
+ strict: false
99
+ }));
100
+ app.get('/', (_req, res) => res.send(sort_keys_1.default(runtimeRequestCollection, { deep: true })));
101
+ app.post('/', (req, res) => {
102
+ const { body } = req;
103
+ if (exports.isRuntimeRequestBody(body)) {
104
+ const fixedPath = `/${body.path}`.replace(/\/\//g, '/');
105
+ body.path = fixedPath;
106
+ runtimeRequestCollection = Object.assign(Object.assign({}, runtimeRequestCollection), { [fixedPath]: body });
107
+ return res.status(204).send();
108
+ }
109
+ return res.status(400).send();
110
+ });
111
+ app.put('/', (req, res) => {
112
+ const { body } = req;
113
+ if (!exports.isRuntimeRequestCollection(body)) {
114
+ return res.status(400).send('BAD_REQUEST_BODY');
115
+ }
116
+ const cleanBody = Object.keys(body).reduce((acc, curr) => {
117
+ const fixedPath = `/${curr}`.replace(/\/\//g, '/');
118
+ const newBody = Object.assign(Object.assign({}, body[curr]), { path: fixedPath });
119
+ return Object.assign(Object.assign({}, acc), { [fixedPath]: newBody });
120
+ }, {});
121
+ runtimeRequestCollection = cleanBody;
122
+ return res.status(204).send();
123
+ });
124
+ app.delete('/', (req, res) => {
125
+ let { path } = req.query;
126
+ if (!path) {
127
+ return res.status(400).send();
128
+ }
129
+ const cleanPath = Array.isArray(path) ? path.map(p => `${p}`) : [`${path}`];
130
+ runtimeRequestCollection = cleanPath.reduce((acc, curr) => {
131
+ const _a = acc, _b = curr, _ = _a[_b], rest = __rest(_a, [typeof _b === "symbol" ? _b : _b + ""]);
132
+ return rest;
133
+ }, runtimeRequestCollection);
134
+ return res.status(204).send();
135
+ });
136
+ const catchAllHandler = (req, res) => {
137
+ const matcher = feather_route_matcher_1.default(runtimeRequestCollection);
138
+ const routeMatch = matcher(req.path);
139
+ if (routeMatch) {
140
+ const reqInfo = routeMatch.value;
141
+ const params = routeMatch.params;
142
+ const method = reqInfo.methods[req.method];
143
+ if (!method) {
144
+ return res.status(404).send();
145
+ }
146
+ const tokenParams = {
147
+ query: req.query,
148
+ params,
149
+ body: req.body,
150
+ headers: req.headers
151
+ };
152
+ if (method.status) {
153
+ const status = typeof method.status === 'function'
154
+ ? method.status(tokenParams)
155
+ : method.status;
156
+ res.status(status);
157
+ }
158
+ if (method.headers) {
159
+ const processedHeaders = Object.keys(method.headers).reduce((acc, curr) => (Object.assign(Object.assign({}, acc), { [curr]: handlebars_1.default.compile(method.headers[curr])(tokenParams) })), {});
160
+ res.set(processedHeaders);
161
+ }
162
+ let { body } = method;
163
+ // if body is a function, execute and then process the response
164
+ if (typeof body === 'function') {
165
+ body = body(tokenParams);
166
+ }
167
+ if (typeof body !== 'string') {
168
+ return res.send(body);
169
+ }
170
+ const template = handlebars_1.default.compile(body);
171
+ const result = template(tokenParams);
172
+ try {
173
+ const jsonResult = JSON.parse(result);
174
+ return res.send(jsonResult);
175
+ }
176
+ catch (_) {
177
+ return res.send(result);
178
+ }
179
+ }
180
+ return res.status(404).send();
181
+ };
182
+ app.get('/*', catchAllHandler);
183
+ app.post('/*', catchAllHandler);
184
+ app.put('/*', catchAllHandler);
185
+ app.patch('/*', catchAllHandler);
186
+ app.delete('/*', catchAllHandler);
187
+ Object.defineProperty(app, 'runtimeRequestCollection', {
188
+ get: () => {
189
+ return lodash_1.cloneDeep(runtimeRequestCollection);
190
+ }
191
+ });
192
+ return app;
193
+ };
194
+ exports.appFactory = appFactory;
195
+ const app = exports.appFactory();
196
+ exports.default = app;
package/index.ts CHANGED
@@ -1,2 +1,2 @@
1
- export * as appV1 from './src/app';
1
+ export * as appV1 from './src/app';
2
2
  export * as appV2 from './src/appV2';
package/jest.config.js CHANGED
@@ -1,4 +1,4 @@
1
- module.exports = {
2
- preset: 'ts-jest',
3
- testEnvironment: 'node',
1
+ module.exports = {
2
+ preset: 'ts-jest',
3
+ testEnvironment: 'node',
4
4
  };
package/package.json CHANGED
@@ -1,55 +1,53 @@
1
- {
2
- "name": "@centeredgesoft/runtime-mock-routes",
3
- "version": "2.1.0",
4
- "description": "",
5
- "main": "build/index.js",
6
- "scripts": {
7
- "build": "tsc --project ./",
8
- "start": "nodemon -r dotenv/config index.ts",
9
- "test": "jest"
10
- },
11
- "bin": {
12
- "runtime-mock-routes": "./build/run.js"
13
- },
14
- "keywords": [],
15
- "author": "",
16
- "license": "MIT",
17
- "repository": {
18
- "type": "git",
19
- "url": "git+https://github.com/CenterEdge/runtime-mock-routes.git"
20
- },
21
- "bugs": {
22
- "url": "https://github.com/CenterEdge/runtime-mock-routes/issues"
23
- },
24
- "homepage": "https://github.com/CenterEdge/runtime-mock-routes#readme",
25
- "dependencies": {
26
- "body-parser": "^1.19.0",
27
- "chance": "^1.1.7",
28
- "commander": "^6.1.0",
29
- "cors": "^2.8.5",
30
- "express": "^4.17.1",
31
- "faker": "^5.1.0",
32
- "feather-route-matcher": "^4.0.0",
33
- "handlebars": "^4.7.6",
34
- "lodash": "^4.17.20",
35
- "sort-keys": "^4.0.0"
36
- },
37
- "devDependencies": {
38
- "@types/body-parser": "^1.19.0",
39
- "@types/chance": "^1.1.0",
40
- "@types/cors": "^2.8.7",
41
- "@types/express": "^4.17.8",
42
- "@types/faker": "^5.1.0",
43
- "@types/jest": "^26.0.14",
44
- "@types/lodash": "^4.14.161",
45
- "@types/node": "^14.11.2",
46
- "@types/supertest": "^2.0.10",
47
- "dotenv": "^8.2.0",
48
- "jest": "^26.4.2",
49
- "nodemon": "^2.0.4",
50
- "supertest": "^4.0.2",
51
- "ts-jest": "^26.4.0",
52
- "ts-node": "^9.0.0",
53
- "typescript": "^4.0.3"
54
- }
55
- }
1
+ {
2
+ "name": "@centeredgesoft/runtime-mock-routes",
3
+ "version": "2.5.0",
4
+ "description": "",
5
+ "main": "build/index.js",
6
+ "scripts": {
7
+ "build": "tsc --project ./",
8
+ "start": "nodemon -r dotenv/config index.ts",
9
+ "test": "jest"
10
+ },
11
+ "bin": {
12
+ "runtime-mock-routes": "./build/run.js"
13
+ },
14
+ "keywords": [],
15
+ "author": "",
16
+ "license": "MIT",
17
+ "repository": {
18
+ "type": "git",
19
+ "url": "git+https://github.com/CenterEdge/runtime-mock-routes.git"
20
+ },
21
+ "bugs": {
22
+ "url": "https://github.com/CenterEdge/runtime-mock-routes/issues"
23
+ },
24
+ "homepage": "https://github.com/CenterEdge/runtime-mock-routes#readme",
25
+ "dependencies": {
26
+ "chance": "^1.1.7",
27
+ "commander": "^6.2.1",
28
+ "cors": "^2.8.5",
29
+ "express": "^4.17.1",
30
+ "faker": "^5.1.0",
31
+ "feather-route-matcher": "^4.0.0",
32
+ "handlebars": "^4.7.6",
33
+ "lodash": "^4.17.20",
34
+ "sort-keys": "^4.2.0"
35
+ },
36
+ "devDependencies": {
37
+ "@types/chance": "^1.1.1",
38
+ "@types/cors": "^2.8.9",
39
+ "@types/express": "^4.17.11",
40
+ "@types/faker": "^5.1.5",
41
+ "@types/jest": "^26.0.20",
42
+ "@types/lodash": "^4.14.167",
43
+ "@types/node": "^14.14.20",
44
+ "@types/supertest": "^2.0.10",
45
+ "dotenv": "^8.2.0",
46
+ "jest": "^26.6.3",
47
+ "nodemon": "^2.0.7",
48
+ "supertest": "^6.0.1",
49
+ "ts-jest": "^26.4.4",
50
+ "ts-node": "^9.1.1",
51
+ "typescript": "^4.1.3"
52
+ }
53
+ }
package/run.ts CHANGED
@@ -1,39 +1,39 @@
1
- #!/usr/bin/env node
2
- import { program } from 'commander';
3
- import { resolve } from 'path';
4
- import { appFactory as appFactoryV1 } from './src/app';
5
- import { appFactory as appFactoryV2 } from './src/appV2';
6
- import { Express } from 'express'
7
-
8
- enum AppVersion {
9
- v1 = 'v1',
10
- v2 = 'v2'
11
- }
12
-
13
- program.version("2.1.0")
14
- .option("-p, --port <port>", "Port to run the server one", process.env.RUNTIME_MOCK_ROUTES_PORT || "8080")
15
- .option("-s, --seed <filePath>", "File path to seed the application", process.env.RUNTIME_MOCK_ROUTES_FILE_PATH)
16
- .option("-a, --appVersion <appVersion>", "App Version to use", AppVersion.v2)
17
-
18
- program.parse(process.argv);
19
- let initialRequests: any = {};
20
- if (program.seed) {
21
- const filePath = resolve(program.seed);
22
- const funcOrJson = require(filePath);
23
- initialRequests = typeof funcOrJson === 'function' ? funcOrJson() : funcOrJson;
24
- }
25
-
26
- type AppFactory = (...args: any[]) => Express;
27
-
28
- const appVersions: Record<AppVersion, AppFactory> = {
29
- v1: appFactoryV1,
30
- v2: appFactoryV2
31
- }
32
- const appFactory = appVersions[program.appVersion] || appFactoryV2;
33
-
34
-
35
- const app = appFactory(initialRequests);
36
-
37
- app.listen(program.port, () => {
38
- console.log(`⚡️[server]: Server is running at http://localhost:${program.port}`);
1
+ #!/usr/bin/env node
2
+ import { program } from 'commander';
3
+ import { resolve } from 'path';
4
+ import { appFactory as appFactoryV1 } from './src/app';
5
+ import { appFactory as appFactoryV2 } from './src/appV2';
6
+ import { Express } from 'express'
7
+
8
+ enum AppVersion {
9
+ v1 = 'v1',
10
+ v2 = 'v2'
11
+ }
12
+
13
+ program.version("2.1.0")
14
+ .option("-p, --port <port>", "Port to run the server one", process.env.RUNTIME_MOCK_ROUTES_PORT || "8080")
15
+ .option("-s, --seed <filePath>", "File path to seed the application", process.env.RUNTIME_MOCK_ROUTES_FILE_PATH)
16
+ .option("-a, --appVersion <appVersion>", "App Version to use", AppVersion.v2)
17
+
18
+ program.parse(process.argv);
19
+ let initialRequests: any = {};
20
+ if (program.seed) {
21
+ const filePath = resolve(program.seed);
22
+ const funcOrJson = require(filePath);
23
+ initialRequests = typeof funcOrJson === 'function' ? funcOrJson() : funcOrJson;
24
+ }
25
+
26
+ type AppFactory = (...args: any[]) => Express;
27
+
28
+ const appVersions: Record<AppVersion, AppFactory> = {
29
+ v1: appFactoryV1,
30
+ v2: appFactoryV2
31
+ }
32
+ const appFactory = appVersions[program.appVersion] || appFactoryV2;
33
+
34
+
35
+ const app = appFactory(initialRequests);
36
+
37
+ app.listen(program.port, () => {
38
+ console.log(`⚡️[server]: Server is running at http://localhost:${program.port}`);
39
39
  });