Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

microgen-client

Package Overview
Dependencies
Maintainers
1
Versions
9
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

microgen-client - npm Package Compare versions

Comparing version 0.0.2 to 0.0.3

51

index.js
const http = require('http');
const url = 'http://localhost:3000';
const client = () => {
const generate = () => {
return new Promise((resolve, reject) => {
http.get(`http://localhost:3000/client?clientId=${process.env.MICROGEN_CLIENT_ID}&clientSecret=${process.env.MICROGEN_CLIENT_SECRET}`, (resp) => {
http.get(`${url}/client?clientId=${process.env.MICROGEN_CLIENT_ID}&clientSecret=${process.env.MICROGEN_CLIENT_SECRET}`, (resp) => {
let data = '';

@@ -19,3 +20,2 @@

} else {
throw new Error("Unathorized");
resolve("failed");

@@ -26,3 +26,2 @@ }

}).on("error", (err) => {
throw new Error("Unathorized");
resolve("failed")

@@ -33,5 +32,47 @@ });

const client = (clientId) => {
return new Promise((resolve, reject) => {
http.get(`${url}/client/${clientId}`, (resp) => {
let data = '';
// A chunk of data has been recieved.
resp.on('data', (chunk) => {
data += chunk;
});
// The whole response has been received. Print out the result.
resp.on('end', () => {
const response = JSON.parse(data);
if(response.status == 'success') {
resolve(data);
} else {
reject("failed");
}
});
}).on("error", (err) => {
reject("failed")
});
})
}
const middleware = ({ app, clientId }) => (req, res, next) => {
if(!app.get("microgen") && clientId) {
client(clientId)
.then(res => {
console.log(res)
console.log(req.hostname)
})
.catch(err => {
console.log(err);
})
} else {
next();
}
}
module.exports = {
client
generate,
middleware
}

2

package.json
{
"name": "microgen-client",
"version": "0.0.2",
"version": "0.0.3",
"description": "",

@@ -5,0 +5,0 @@ "main": "index.js",

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc