Comparing version 0.0.1 to 0.0.2
61
index.js
@@ -1,57 +0,8 @@ | ||
const fs = require("fs"); | ||
const got = require("got"); | ||
const FormData = require("form-data"); | ||
const package = require("./package.json"); | ||
const { setConfig, getConfig } = require('./src/config'); | ||
const { upload } = require('./src/upload'); | ||
const alphatech = {}; | ||
alphatech.configure = function (config = {}) { | ||
alphatech.config = { | ||
...config, | ||
domain: `https://api.alpha.tech`, | ||
}; | ||
module.exports = { | ||
setConfig, | ||
getConfig, | ||
upload, | ||
}; | ||
8; | ||
alphatech.drive = { files: {} }; | ||
alphatech.drive.files.upload = async function (file, options = {}) { | ||
try { | ||
if (!alphatech.config) { | ||
throw new Error("[alphatech] Not configured"); | ||
} | ||
if (!file) { | ||
throw new Error("[alphatech] `file` is missing"); | ||
} | ||
const form = new FormData(); | ||
if (typeof file === "string") { | ||
form.append("file", fs.createReadStream(file)); | ||
} else { | ||
form.append("file", file); | ||
} | ||
for (const [key, value] of Object.entries(options)) { | ||
if (value instanceof Object) { | ||
form.append(key, JSON.stringify(value)); | ||
} else { | ||
form.append(key, value); | ||
} | ||
} | ||
const response = await got | ||
.post(`${alphatech.config.domain}/drive/files/upload`, { | ||
body: form, | ||
headers: { | ||
"x-alphatech-javascript-version": package.version, | ||
authorization: `Bearer ${alphatech.config.token}.${alphatech.config.teamId}`, | ||
}, | ||
}) | ||
.json(); | ||
return response; | ||
} catch (err) { | ||
throw err; | ||
} | ||
}; | ||
module.exports = alphatech; |
{ | ||
"name": "alphatech", | ||
"version": "0.0.1", | ||
"version": "0.0.2", | ||
"description": "", | ||
@@ -20,5 +20,16 @@ "main": "index.js", | ||
"dependencies": { | ||
"file-type": "^14.3.0", | ||
"form-data": "^3.0.0", | ||
"got": "^11.1.2" | ||
"got": "^11.1.2", | ||
"image-size": "^0.8.3", | ||
"mime": "^2.4.5" | ||
}, | ||
"devDependencies": { | ||
"eslint": "^6.8.0", | ||
"eslint-config-airbnb-base": "^14.1.0", | ||
"eslint-config-prettier": "^6.11.0", | ||
"eslint-plugin-import": "^2.20.2", | ||
"eslint-plugin-prettier": "^3.1.3", | ||
"prettier": "^2.0.5" | ||
} | ||
} |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 1 instance in 1 package
6312
15
205
5
6
2
1
+ Addedfile-type@^14.3.0
+ Addedimage-size@^0.8.3
+ Addedmime@^2.4.5
+ Added@tokenizer/token@0.1.10.3.0(transitive)
+ Addedfile-type@14.7.1(transitive)
+ Addedieee754@1.2.1(transitive)
+ Addedimage-size@0.8.3(transitive)
+ Addedinherits@2.0.4(transitive)
+ Addedis-typedarray@1.0.0(transitive)
+ Addedmime@2.6.0(transitive)
+ Addedpeek-readable@4.1.0(transitive)
+ Addedqueue@6.0.1(transitive)
+ Addedreadable-web-to-node-stream@2.0.0(transitive)
+ Addedstrtok3@6.3.0(transitive)
+ Addedtoken-types@2.1.1(transitive)
+ Addedtypedarray-to-buffer@3.1.5(transitive)