add net-level client and helper to apps api
This commit is contained in:
parent
f4276bb8e1
commit
7abc9a0426
2 changed files with 16 additions and 1 deletions
16
app.js
16
app.js
|
|
@ -13,6 +13,7 @@ const moment = require('moment');
|
||||||
const agent = require('express-useragent');
|
const agent = require('express-useragent');
|
||||||
const license = require_fresh('./src/moto/license.js');
|
const license = require_fresh('./src/moto/license.js');
|
||||||
const version = license.VERSION || "rogue";
|
const version = license.VERSION || "rogue";
|
||||||
|
const netdb = require('@gridspace/net-level-client');
|
||||||
|
|
||||||
const fileCache = {};
|
const fileCache = {};
|
||||||
const code_src = {};
|
const code_src = {};
|
||||||
|
|
@ -42,6 +43,18 @@ const EventEmitter = require('events');
|
||||||
class AppEmitter extends EventEmitter {}
|
class AppEmitter extends EventEmitter {}
|
||||||
const events = new AppEmitter();
|
const events = new AppEmitter();
|
||||||
|
|
||||||
|
netdb.create = async function(map = {}) {
|
||||||
|
if (util.isfile(map.conf)) {
|
||||||
|
Object.assign(map, JSON.parse(fs.readFileSync(map.conf)));
|
||||||
|
}
|
||||||
|
const client = new netdb();
|
||||||
|
if (map.host && map.port) await client.open(map.host, map.port);
|
||||||
|
if (map.user && map.pass) await client.auth(map.user, map.pass);
|
||||||
|
if (map.base) await client.use(map.base);
|
||||||
|
logger.log({ netdb: map.host, user: map.user, base: map.base });
|
||||||
|
return client;
|
||||||
|
};
|
||||||
|
|
||||||
function addonce(array, v) {
|
function addonce(array, v) {
|
||||||
if (array.indexOf(v) < 0) {
|
if (array.indexOf(v) < 0) {
|
||||||
array.push(v);
|
array.push(v);
|
||||||
|
|
@ -318,7 +331,8 @@ function initModule(mod, file, dir) {
|
||||||
env: mod.env,
|
env: mod.env,
|
||||||
pkg: {
|
pkg: {
|
||||||
agent,
|
agent,
|
||||||
moment
|
moment,
|
||||||
|
netdb,
|
||||||
},
|
},
|
||||||
mod: mods,
|
mod: mods,
|
||||||
util: {
|
util: {
|
||||||
|
|
|
||||||
|
|
@ -22,6 +22,7 @@
|
||||||
],
|
],
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@fortawesome/fontawesome-free": "^6.1.1",
|
"@fortawesome/fontawesome-free": "^6.1.1",
|
||||||
|
"@gridspace/net-level-client": "^0.2.3",
|
||||||
"@tweenjs/tween.js": "^16.6.0",
|
"@tweenjs/tween.js": "^16.6.0",
|
||||||
"base64-js": "^1.5.1",
|
"base64-js": "^1.5.1",
|
||||||
"buffer-crc32": "^0.2.13",
|
"buffer-crc32": "^0.2.13",
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue