quidproquo-dev-server 0.0.228 → 0.0.229
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/lib/commonjs/allServiceConfig.js +2 -4
- package/lib/commonjs/main.d.ts +1 -1
- package/lib/commonjs/main.js +7 -8
- package/lib/commonjs/types/DevServerConfig.d.ts +3 -0
- package/lib/esm/allServiceConfig.js +2 -4
- package/lib/esm/main.d.ts +1 -1
- package/lib/esm/main.js +5 -6
- package/lib/esm/types/DevServerConfig.d.ts +3 -0
- package/package.json +4 -4
- package/lib/commonjs/dynamicModuleLoader/dynamicModuleLoader.d.ts +0 -3
- package/lib/commonjs/dynamicModuleLoader/dynamicModuleLoader.js +0 -17
- package/lib/commonjs/dynamicModuleLoader/index.d.ts +0 -1
- package/lib/commonjs/dynamicModuleLoader/index.js +0 -17
- package/lib/esm/dynamicModuleLoader/dynamicModuleLoader.d.ts +0 -3
- package/lib/esm/dynamicModuleLoader/dynamicModuleLoader.js +0 -6
- package/lib/esm/dynamicModuleLoader/index.d.ts +0 -1
- package/lib/esm/dynamicModuleLoader/index.js +0 -1
|
@@ -2,13 +2,11 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.getAllServiceConfigs = void 0;
|
|
4
4
|
const quidproquo_1 = require("quidproquo");
|
|
5
|
-
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
6
|
-
// @ts-ignore - Special webpack loader
|
|
7
|
-
const quidproquo_dynamic_loader_1 = require("quidproquo-dynamic-loader");
|
|
8
5
|
// Create an async function to fetch all services
|
|
9
6
|
function getAllServiceConfigs(devServerConfig) {
|
|
7
|
+
// Clone it
|
|
8
|
+
const allServices = JSON.parse(JSON.stringify(devServerConfig.qpqConfigs));
|
|
10
9
|
// Iterate over each enum value and dynamically import the corresponding infrastructure
|
|
11
|
-
const allServices = quidproquo_dynamic_loader_1.qpqConfigs;
|
|
12
10
|
const rootDomain = `${devServerConfig.serverDomain}:${devServerConfig.serverPort}`;
|
|
13
11
|
// TODO: Make this pure
|
|
14
12
|
// Overload the domain settings to represent the local env
|
package/lib/commonjs/main.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { DevServerConfig } from './types';
|
|
2
|
-
export declare const
|
|
2
|
+
export declare const startDevServer: (devServerConfig: DevServerConfig) => Promise<void>;
|
package/lib/commonjs/main.js
CHANGED
|
@@ -13,7 +13,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
13
13
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
14
14
|
};
|
|
15
15
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
16
|
-
exports.
|
|
16
|
+
exports.startDevServer = void 0;
|
|
17
17
|
/* eslint-disable no-console */
|
|
18
18
|
const body_parser_1 = __importDefault(require("body-parser"));
|
|
19
19
|
const express_1 = __importDefault(require("express"));
|
|
@@ -22,7 +22,6 @@ const path_1 = __importDefault(require("path"));
|
|
|
22
22
|
const quidproquo_1 = require("quidproquo");
|
|
23
23
|
const route_1 = require("./entry/route");
|
|
24
24
|
const allServiceConfig_1 = require("./allServiceConfig");
|
|
25
|
-
const dynamicModuleLoader_1 = require("./dynamicModuleLoader");
|
|
26
25
|
const getServiceBaseDomain = (qpqConfig, devServerConfig) => quidproquo_1.qpqWebServerUtils.getDomainRoot(`${devServerConfig.serverDomain}:${devServerConfig.serverPort}`, quidproquo_1.qpqCoreUtils.getApplicationModuleEnvironment(qpqConfig), quidproquo_1.qpqCoreUtils.getApplicationModuleFeature(qpqConfig));
|
|
27
26
|
const getApiDomainsFromConfig = (qpqConfig, devServerConfig) => {
|
|
28
27
|
const baseDomain = getServiceBaseDomain(qpqConfig, devServerConfig);
|
|
@@ -39,11 +38,11 @@ const getApiDomainsFromConfig = (qpqConfig, devServerConfig) => {
|
|
|
39
38
|
}));
|
|
40
39
|
return apiDomains;
|
|
41
40
|
};
|
|
42
|
-
const getDynamicModuleLoader = (qpqConfig) => {
|
|
41
|
+
const getDynamicModuleLoader = (qpqConfig, devServerConfig) => {
|
|
43
42
|
const serviceName = quidproquo_1.qpqCoreUtils.getApplicationModuleName(qpqConfig);
|
|
44
|
-
return (runtime) => __awaiter(void 0, void 0, void 0, function* () { return
|
|
43
|
+
return (runtime) => __awaiter(void 0, void 0, void 0, function* () { return devServerConfig.dynamicModuleLoader(serviceName, runtime); });
|
|
45
44
|
};
|
|
46
|
-
const
|
|
45
|
+
const startDevServer = (devServerConfig) => __awaiter(void 0, void 0, void 0, function* () {
|
|
47
46
|
const allServiceConfig = yield (0, allServiceConfig_1.getAllServiceConfigs)(devServerConfig);
|
|
48
47
|
const app = (0, express_1.default)();
|
|
49
48
|
app.use((0, multer_1.default)().any());
|
|
@@ -89,7 +88,7 @@ const spinUpService = (devServerConfig) => __awaiter(void 0, void 0, void 0, fun
|
|
|
89
88
|
let runtimeModule = quidproquo_1.askProcessEvent;
|
|
90
89
|
if (serviceLog.runtimeType === quidproquo_1.QpqRuntimeType.EXECUTE_STORY) {
|
|
91
90
|
const [srcEntry, module] = serviceLog.tags[0].split('::');
|
|
92
|
-
const loadedModule = yield
|
|
91
|
+
const loadedModule = yield devServerConfig.dynamicModuleLoader(serviceLog.moduleName, srcEntry);
|
|
93
92
|
runtimeModule = loadedModule[module];
|
|
94
93
|
}
|
|
95
94
|
const result = yield (0, quidproquo_1.qpqExecuteLog)(serviceLog, runtimeModule);
|
|
@@ -119,7 +118,7 @@ const spinUpService = (devServerConfig) => __awaiter(void 0, void 0, void 0, fun
|
|
|
119
118
|
mimetype: file.mimetype,
|
|
120
119
|
}));
|
|
121
120
|
}
|
|
122
|
-
const response = yield (0, route_1.route)(event, apiConfig.qpqConfig, getDynamicModuleLoader(apiConfig.qpqConfig));
|
|
121
|
+
const response = yield (0, route_1.route)(event, apiConfig.qpqConfig, getDynamicModuleLoader(apiConfig.qpqConfig, devServerConfig));
|
|
123
122
|
for (const [header, value] of Object.entries(response.headers)) {
|
|
124
123
|
res.set(header, value);
|
|
125
124
|
}
|
|
@@ -140,4 +139,4 @@ const spinUpService = (devServerConfig) => __awaiter(void 0, void 0, void 0, fun
|
|
|
140
139
|
console.log(`⚡️⚡️⚡️[Qpq - Dev Server]⚡️⚡️⚡️: Server is running at [http://${baseDomain}]`);
|
|
141
140
|
});
|
|
142
141
|
});
|
|
143
|
-
exports.
|
|
142
|
+
exports.startDevServer = startDevServer;
|
|
@@ -1,4 +1,7 @@
|
|
|
1
|
+
import { QPQConfig, QpqFunctionRuntime } from 'quidproquo-core';
|
|
1
2
|
export type DevServerConfig = {
|
|
2
3
|
serverDomain: 'localhost';
|
|
3
4
|
serverPort: 8080;
|
|
5
|
+
dynamicModuleLoader: <T = any>(serviceName: string, modulePath: QpqFunctionRuntime) => Promise<T>;
|
|
6
|
+
qpqConfigs: QPQConfig[];
|
|
4
7
|
};
|
|
@@ -1,11 +1,9 @@
|
|
|
1
1
|
import { qpqCoreUtils, qpqWebServerUtils } from 'quidproquo';
|
|
2
|
-
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
3
|
-
// @ts-ignore - Special webpack loader
|
|
4
|
-
import { qpqConfigs } from 'quidproquo-dynamic-loader';
|
|
5
2
|
// Create an async function to fetch all services
|
|
6
3
|
export function getAllServiceConfigs(devServerConfig) {
|
|
4
|
+
// Clone it
|
|
5
|
+
const allServices = JSON.parse(JSON.stringify(devServerConfig.qpqConfigs));
|
|
7
6
|
// Iterate over each enum value and dynamically import the corresponding infrastructure
|
|
8
|
-
const allServices = qpqConfigs;
|
|
9
7
|
const rootDomain = `${devServerConfig.serverDomain}:${devServerConfig.serverPort}`;
|
|
10
8
|
// TODO: Make this pure
|
|
11
9
|
// Overload the domain settings to represent the local env
|
package/lib/esm/main.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { DevServerConfig } from './types';
|
|
2
|
-
export declare const
|
|
2
|
+
export declare const startDevServer: (devServerConfig: DevServerConfig) => Promise<void>;
|
package/lib/esm/main.js
CHANGED
|
@@ -7,7 +7,6 @@ import path from 'path';
|
|
|
7
7
|
import { askProcessEvent, qpqCoreUtils, qpqExecuteLog, QpqRuntimeType, qpqWebServerUtils, } from 'quidproquo';
|
|
8
8
|
import { route } from './entry/route';
|
|
9
9
|
import { getAllServiceConfigs } from './allServiceConfig';
|
|
10
|
-
import { dynamicModuleLoader } from './dynamicModuleLoader';
|
|
11
10
|
const getServiceBaseDomain = (qpqConfig, devServerConfig) => qpqWebServerUtils.getDomainRoot(`${devServerConfig.serverDomain}:${devServerConfig.serverPort}`, qpqCoreUtils.getApplicationModuleEnvironment(qpqConfig), qpqCoreUtils.getApplicationModuleFeature(qpqConfig));
|
|
12
11
|
const getApiDomainsFromConfig = (qpqConfig, devServerConfig) => {
|
|
13
12
|
const baseDomain = getServiceBaseDomain(qpqConfig, devServerConfig);
|
|
@@ -24,11 +23,11 @@ const getApiDomainsFromConfig = (qpqConfig, devServerConfig) => {
|
|
|
24
23
|
}));
|
|
25
24
|
return apiDomains;
|
|
26
25
|
};
|
|
27
|
-
const getDynamicModuleLoader = (qpqConfig) => {
|
|
26
|
+
const getDynamicModuleLoader = (qpqConfig, devServerConfig) => {
|
|
28
27
|
const serviceName = qpqCoreUtils.getApplicationModuleName(qpqConfig);
|
|
29
|
-
return async (runtime) => dynamicModuleLoader(serviceName, runtime);
|
|
28
|
+
return async (runtime) => devServerConfig.dynamicModuleLoader(serviceName, runtime);
|
|
30
29
|
};
|
|
31
|
-
export const
|
|
30
|
+
export const startDevServer = async (devServerConfig) => {
|
|
32
31
|
const allServiceConfig = await getAllServiceConfigs(devServerConfig);
|
|
33
32
|
const app = express();
|
|
34
33
|
app.use(multer().any());
|
|
@@ -74,7 +73,7 @@ export const spinUpService = async (devServerConfig) => {
|
|
|
74
73
|
let runtimeModule = askProcessEvent;
|
|
75
74
|
if (serviceLog.runtimeType === QpqRuntimeType.EXECUTE_STORY) {
|
|
76
75
|
const [srcEntry, module] = serviceLog.tags[0].split('::');
|
|
77
|
-
const loadedModule = await dynamicModuleLoader(serviceLog.moduleName, srcEntry);
|
|
76
|
+
const loadedModule = await devServerConfig.dynamicModuleLoader(serviceLog.moduleName, srcEntry);
|
|
78
77
|
runtimeModule = loadedModule[module];
|
|
79
78
|
}
|
|
80
79
|
const result = await qpqExecuteLog(serviceLog, runtimeModule);
|
|
@@ -104,7 +103,7 @@ export const spinUpService = async (devServerConfig) => {
|
|
|
104
103
|
mimetype: file.mimetype,
|
|
105
104
|
}));
|
|
106
105
|
}
|
|
107
|
-
const response = await route(event, apiConfig.qpqConfig, getDynamicModuleLoader(apiConfig.qpqConfig));
|
|
106
|
+
const response = await route(event, apiConfig.qpqConfig, getDynamicModuleLoader(apiConfig.qpqConfig, devServerConfig));
|
|
108
107
|
for (const [header, value] of Object.entries(response.headers)) {
|
|
109
108
|
res.set(header, value);
|
|
110
109
|
}
|
|
@@ -1,4 +1,7 @@
|
|
|
1
|
+
import { QPQConfig, QpqFunctionRuntime } from 'quidproquo-core';
|
|
1
2
|
export type DevServerConfig = {
|
|
2
3
|
serverDomain: 'localhost';
|
|
3
4
|
serverPort: 8080;
|
|
5
|
+
dynamicModuleLoader: <T = any>(serviceName: string, modulePath: QpqFunctionRuntime) => Promise<T>;
|
|
6
|
+
qpqConfigs: QPQConfig[];
|
|
4
7
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "quidproquo-dev-server",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.229",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "./lib/commonjs/index.js",
|
|
6
6
|
"module": "./lib/esm/index.js",
|
|
@@ -30,12 +30,12 @@
|
|
|
30
30
|
"homepage": "https://github.com/joe-coady/quidproquo#readme",
|
|
31
31
|
"dependencies": {
|
|
32
32
|
"multer": "^1.4.5-lts.1",
|
|
33
|
-
"quidproquo-core": "0.0.
|
|
34
|
-
"quidproquo-webserver": "0.0.
|
|
33
|
+
"quidproquo-core": "0.0.229",
|
|
34
|
+
"quidproquo-webserver": "0.0.229"
|
|
35
35
|
},
|
|
36
36
|
"devDependencies": {
|
|
37
37
|
"@types/multer": "^1.4.12",
|
|
38
|
-
"quidproquo-tsconfig": "0.0.
|
|
38
|
+
"quidproquo-tsconfig": "0.0.229",
|
|
39
39
|
"typescript": "^4.9.3"
|
|
40
40
|
}
|
|
41
41
|
}
|
|
@@ -1,17 +0,0 @@
|
|
|
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.getQpqConfigs = exports.dynamicModuleLoader = void 0;
|
|
13
|
-
const quidproquo_dynamic_loader_1 = require("quidproquo-dynamic-loader");
|
|
14
|
-
const dynamicModuleLoader = (serviceName, runtime) => __awaiter(void 0, void 0, void 0, function* () { return (0, quidproquo_dynamic_loader_1.qpqDynamicModuleLoaderForService)(serviceName, runtime); });
|
|
15
|
-
exports.dynamicModuleLoader = dynamicModuleLoader;
|
|
16
|
-
const getQpqConfigs = () => quidproquo_dynamic_loader_1.qpqConfigs;
|
|
17
|
-
exports.getQpqConfigs = getQpqConfigs;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from './dynamicModuleLoader';
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
-
};
|
|
16
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
__exportStar(require("./dynamicModuleLoader"), exports);
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
import { qpqConfigs, qpqDynamicModuleLoaderForService,
|
|
2
|
-
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
3
|
-
// @ts-ignore - Special webpack loader
|
|
4
|
-
} from 'quidproquo-dynamic-loader';
|
|
5
|
-
export const dynamicModuleLoader = async (serviceName, runtime) => qpqDynamicModuleLoaderForService(serviceName, runtime);
|
|
6
|
-
export const getQpqConfigs = () => qpqConfigs;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from './dynamicModuleLoader';
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from './dynamicModuleLoader';
|