godprotocol 2.3.28 → 2.3.30
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/Godprotocol.js +13 -0
- package/package.json +1 -1
- package/server/Routable/Services.js +21 -3
- package/server/version_control.js +3 -2
package/Godprotocol.js
CHANGED
|
@@ -81,6 +81,19 @@ class GodProtocol {
|
|
|
81
81
|
await this.route_table.load_services(services);
|
|
82
82
|
};
|
|
83
83
|
|
|
84
|
+
_loaded_routers = [];
|
|
85
|
+
|
|
86
|
+
load_locals = async (services, opts = {}) => {
|
|
87
|
+
let { services_config } = opts;
|
|
88
|
+
|
|
89
|
+
for (let service of services) {
|
|
90
|
+
if (this._loaded_routers.includes(service.router)) continue;
|
|
91
|
+
|
|
92
|
+
this._loaded_routers.push(service.router);
|
|
93
|
+
await service.router(this, { services_config });
|
|
94
|
+
}
|
|
95
|
+
};
|
|
96
|
+
|
|
84
97
|
add_router = async (version, routes, opts = {}) => {
|
|
85
98
|
if (opts.alias) {
|
|
86
99
|
for (let o of opts.alias) {
|
package/package.json
CHANGED
|
@@ -82,7 +82,7 @@ class Services {
|
|
|
82
82
|
"Content-Type": "application/json",
|
|
83
83
|
Accept: "application/json",
|
|
84
84
|
"x-api-version":
|
|
85
|
-
servic.local && !header?.api_version
|
|
85
|
+
servic.local && !header?.api_version?.startsWith(`${servic.local}:`)
|
|
86
86
|
? `${servic.local}:${header?.api_version || servic.api_version}`
|
|
87
87
|
: header?.api_version || servic.api_version || "v1",
|
|
88
88
|
};
|
|
@@ -158,10 +158,28 @@ class Services {
|
|
|
158
158
|
};
|
|
159
159
|
|
|
160
160
|
version_db = async (ver) => {
|
|
161
|
+
let curr_ver = this.active_version;
|
|
161
162
|
let version = await this.get_version(ver);
|
|
162
|
-
if (!version)
|
|
163
|
+
if (!version) {
|
|
164
|
+
let vers = Object.keys(this.versions);
|
|
163
165
|
|
|
164
|
-
|
|
166
|
+
for (let v = 0; v < vers.length; v++) {
|
|
167
|
+
let vrr = vers[v];
|
|
168
|
+
|
|
169
|
+
if (vrr.startsWith(`${ver}:`)) {
|
|
170
|
+
version = this.get_version(vrr);
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
if (!version) {
|
|
175
|
+
return;
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
let db = await this.platform_db();
|
|
179
|
+
|
|
180
|
+
this.get_version(curr_ver);
|
|
181
|
+
|
|
182
|
+
return db;
|
|
165
183
|
};
|
|
166
184
|
|
|
167
185
|
platform_db = async (name) => {
|
|
@@ -225,7 +225,7 @@ const version_middleware = async (req, res, routers) => {
|
|
|
225
225
|
|
|
226
226
|
// EXECUTE
|
|
227
227
|
error_stage = "Handler";
|
|
228
|
-
|
|
228
|
+
let payload = {
|
|
229
229
|
body,
|
|
230
230
|
route: name,
|
|
231
231
|
headers: req.headers,
|
|
@@ -234,7 +234,8 @@ const version_middleware = async (req, res, routers) => {
|
|
|
234
234
|
services: router.get_service,
|
|
235
235
|
method: req.method,
|
|
236
236
|
memory: router.gp.memory,
|
|
237
|
-
}
|
|
237
|
+
};
|
|
238
|
+
const result = await router.execute(name, payload);
|
|
238
239
|
|
|
239
240
|
// WEBHOOK AFTER
|
|
240
241
|
if (!isWebhook && version !== "*") {
|