godprotocol 2.2.90 → 2.2.91
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 +9 -1
- package/package.json +1 -1
- package/server/version_control.js +16 -8
package/Godprotocol.js
CHANGED
|
@@ -7,10 +7,18 @@ class GodProtocol {
|
|
|
7
7
|
|
|
8
8
|
this.static_path = config.static_path;
|
|
9
9
|
this.api_key = config.api_key;
|
|
10
|
-
this.platform_uri = config.platform_uri;
|
|
10
|
+
this.platform_uri = this.domain_name(config.platform_uri);
|
|
11
11
|
this.route_table = new Route_table(this);
|
|
12
12
|
}
|
|
13
13
|
|
|
14
|
+
domain_name = (uri) => {
|
|
15
|
+
if (!uri.includes(".")) {
|
|
16
|
+
uri = `${uri}.savvyaisolution.com`;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
return uri;
|
|
20
|
+
};
|
|
21
|
+
|
|
14
22
|
prior_callback = (prior) => {
|
|
15
23
|
this.webhook_prior = prior;
|
|
16
24
|
};
|
package/package.json
CHANGED
|
@@ -88,6 +88,7 @@ const respond = (result, res) => {
|
|
|
88
88
|
|
|
89
89
|
const version_middleware = async (req, res, routers) => {
|
|
90
90
|
let error_stage = "Version Middleware";
|
|
91
|
+
|
|
91
92
|
try {
|
|
92
93
|
applyCors(req, res);
|
|
93
94
|
|
|
@@ -96,18 +97,25 @@ const version_middleware = async (req, res, routers) => {
|
|
|
96
97
|
return res.end();
|
|
97
98
|
}
|
|
98
99
|
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
const parsedUrl = new URL(req.url, `http://${req.headers.host}`);
|
|
100
|
+
const parsed_url = new URL(req.url, `http://${req.headers.host}`);
|
|
101
|
+
const pathname = parsed_url.pathname;
|
|
102
102
|
|
|
103
|
-
|
|
103
|
+
// STATIC ROUTE DETECTION
|
|
104
|
+
if (routers.static_path && pathname.startsWith(routers.static_path)) {
|
|
105
|
+
return serveStaticFile(req, res);
|
|
106
|
+
}
|
|
104
107
|
|
|
105
|
-
|
|
106
|
-
if (routers.static_path && pathname.startsWith(routers.static_path)) {
|
|
107
|
-
return serveStaticFile(req, res);
|
|
108
|
-
}
|
|
108
|
+
let version;
|
|
109
109
|
|
|
110
|
+
// Match:
|
|
111
|
+
// /api/v1/...
|
|
112
|
+
// /api/v2/...
|
|
113
|
+
// /api/v3/...
|
|
114
|
+
const versionMatch = pathname.match(/^\/api\/(v\d+)(\/|$)/i);
|
|
115
|
+
if (req.method === "GET") {
|
|
110
116
|
version = "__GET__";
|
|
117
|
+
} else if (versionMatch) {
|
|
118
|
+
version = versionMatch[1];
|
|
111
119
|
} else {
|
|
112
120
|
version = req.headers["x-api-version"] || "v1";
|
|
113
121
|
}
|