godprotocol 2.2.90 → 2.2.92

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 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.uri_default_domain(config.platform_uri);
11
11
  this.route_table = new Route_table(this);
12
12
  }
13
13
 
14
+ uri_default_domain = (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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "godprotocol",
3
- "version": "2.2.90",
3
+ "version": "2.2.92",
4
4
  "description": "A distributed computing environment for Web 4.0 — integrating AI, decentralisation, and virtual computation.",
5
5
  "main": "Index.js",
6
6
  "type": "module",
@@ -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,22 +97,30 @@ const version_middleware = async (req, res, routers) => {
96
97
  return res.end();
97
98
  }
98
99
 
99
- let version;
100
- if (req.method === "GET") {
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
- const pathname = parsedUrl.pathname;
103
+ // STATIC ROUTE DETECTION
104
+ if (routers.static_path && pathname.startsWith(routers.static_path)) {
105
+ return serveStaticFile(req, res);
106
+ }
104
107
 
105
- // STATIC ROUTE DETECTION
106
- if (routers.static_path && pathname.startsWith(routers.static_path)) {
107
- return serveStaticFile(req, res);
108
- }
108
+ let version;
109
109
 
110
+ const versionMatch = pathname.match(/^\/api\/(v\d+)(\/|$)/i);
111
+ if (req.method === "GET") {
110
112
  version = "__GET__";
113
+ } else if (versionMatch) {
114
+ version = versionMatch[1];
111
115
  } else {
112
116
  version = req.headers["x-api-version"] || "v1";
113
117
  }
114
118
 
119
+ if (headers["x-platform"])
120
+ headers["x-platform"] = routers.gp.uri_default_domain(
121
+ headers["x-platform"],
122
+ );
123
+
115
124
  const versionRouter = await routers.get_version(version);
116
125
 
117
126
  if (!versionRouter) {