godprotocol 2.2.80 → 2.2.83

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
@@ -25,7 +25,7 @@ class GodProtocol {
25
25
 
26
26
  add_router = async (version, routes, opts = {}) => {
27
27
  if (opts.is_old) {
28
- await this.route_table.init_version("v1", { is_old: true });
28
+ await this.route_table.init_version(version, { is_old: true });
29
29
  this.route_table.versions[version].routes = routes;
30
30
  return;
31
31
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "godprotocol",
3
- "version": "2.2.80",
3
+ "version": "2.2.83",
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",
@@ -33,6 +33,7 @@
33
33
  "homepage": "https://github.com/immanuel-savvy/GodProtocol#readme",
34
34
  "dependencies": {
35
35
  "aircode4": "latest",
36
+ "busboy": "^1.6.0",
36
37
  "generalised-datastore": "latest",
37
38
  "@godprotocol/repositories": "^1.1.27"
38
39
  },
@@ -174,9 +174,9 @@ class Headers extends Services {
174
174
  headers["authorization"] = `Bearer ${authorization}`;
175
175
  }
176
176
 
177
- let third_party = xplatform === this.platform_uri;
177
+ let third_party = xplatform !== this.platform_uri;
178
178
  let res = await fetch(
179
- `${gp_services.profile}/${third_party ? "me" : "third_party_me"}`,
179
+ `${gp_services.profile}/${third_party ? "third_party_me" : "me"}`,
180
180
  {
181
181
  method: "post",
182
182
  headers: {
@@ -0,0 +1,42 @@
1
+ import Busboy from "busboy";
2
+ import fs from "fs";
3
+ import path from "path";
4
+
5
+ const parseMultipart = (req, gp) => {
6
+ return new Promise((resolve, reject) => {
7
+ const busboy = Busboy({ headers: req.headers });
8
+
9
+ const fields = {};
10
+ let filePath = null;
11
+
12
+ const uploadDir = `./${gp.static_path.slice(1)}/uploads`;
13
+ if (!fs.existsSync(uploadDir)) {
14
+ fs.mkdirSync(uploadDir, { recursive: true });
15
+ }
16
+
17
+ busboy.on("file", (name, file, info) => {
18
+ const filename = `${Date.now()}-${info.filename}`;
19
+ filePath = path.join(uploadDir, filename);
20
+
21
+ const stream = fs.createWriteStream(filePath);
22
+ file.pipe(stream);
23
+ });
24
+
25
+ busboy.on("field", (name, value) => {
26
+ fields[name] = value;
27
+ });
28
+
29
+ busboy.on("finish", () => {
30
+ resolve({
31
+ ...fields,
32
+ file_path: filePath,
33
+ });
34
+ });
35
+
36
+ busboy.on("error", reject);
37
+
38
+ req.pipe(busboy);
39
+ });
40
+ };
41
+
42
+ export default parseMultipart;