Merge pull request #86 from theta42/conf
Using the simpleworks conf now
This commit is contained in:
+1
-1
@@ -7,7 +7,7 @@
|
|||||||
var app = require('../app');
|
var app = require('../app');
|
||||||
var debug = require('debug')('proxy-api:server');
|
var debug = require('debug')('proxy-api:server');
|
||||||
var http = require('http');
|
var http = require('http');
|
||||||
const conf = require('../conf');
|
const conf = require('@simpleworkjs/conf');
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get port from environment and store in Express.
|
* Get port from environment and store in Express.
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
|
// Using https://github.com/simpleworkjs/conf to handle configuration
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
userModel: 'redis', // pam, redis, ldap
|
userModel: 'redis', // pam, redis, ldap
|
||||||
|
|||||||
@@ -1,32 +0,0 @@
|
|||||||
'use strict';
|
|
||||||
|
|
||||||
const extend = require('extend');
|
|
||||||
|
|
||||||
const environment = process.env.NODE_ENV || 'development';
|
|
||||||
|
|
||||||
function load(filePath, required){
|
|
||||||
try {
|
|
||||||
return require(filePath);
|
|
||||||
} catch(error){
|
|
||||||
if(error.name === 'SyntaxError'){
|
|
||||||
console.error(`Loading ${filePath} file failed!\n`, error);
|
|
||||||
process.exit(1);
|
|
||||||
} else if (error.code === 'MODULE_NOT_FOUND'){
|
|
||||||
console.warn(`No config file ${filePath} FOUND! This may cause issues...`);
|
|
||||||
if (required){
|
|
||||||
process.exit(1);
|
|
||||||
}
|
|
||||||
return {};
|
|
||||||
}else{
|
|
||||||
console.dir(`Unknown error in loading ${filePath} config file.\n`, error);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
module.exports = extend(
|
|
||||||
true, // enable deep copy
|
|
||||||
load('./base', true),
|
|
||||||
load(`./${environment}`),
|
|
||||||
load('./secrets'),
|
|
||||||
{environment}
|
|
||||||
);
|
|
||||||
@@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
const {createClient} = require('redis');
|
const {createClient} = require('redis');
|
||||||
const objValidate = require('../utils/object_validate');
|
const objValidate = require('../utils/object_validate');
|
||||||
const conf = require('../conf/conf');
|
const conf = require('@simpleworkjs/conf');
|
||||||
|
|
||||||
const client = createClient({});
|
const client = createClient({});
|
||||||
|
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
const crypto = require("crypto");
|
const crypto = require("crypto");
|
||||||
|
|
||||||
const conf = require('../conf');
|
const conf = require('@simpleworkjs/conf');
|
||||||
const Table = require('../utils/redis_model');
|
const Table = require('../utils/redis_model');
|
||||||
const ModelPs = require('../utils/model_pubsub');
|
const ModelPs = require('../utils/model_pubsub');
|
||||||
|
|
||||||
@@ -178,7 +178,7 @@ DnsProvider.register(ModelPs(DnsProvider))
|
|||||||
|
|
||||||
|
|
||||||
if(require.main === module){(async function(){try{
|
if(require.main === module){(async function(){try{
|
||||||
const conf = require('../conf');
|
const conf = require('@simpleworkjs/conf');
|
||||||
|
|
||||||
// console.log(await DnsProvider.findall());
|
// console.log(await DnsProvider.findall());
|
||||||
|
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ const ModelPs = require('../utils/model_pubsub');
|
|||||||
|
|
||||||
const tldExtract = require('tld-extract').parse_host;
|
const tldExtract = require('tld-extract').parse_host;
|
||||||
const LetsEncrypt = require('../utils/letsencrypt');
|
const LetsEncrypt = require('../utils/letsencrypt');
|
||||||
const conf = require('../conf');
|
const conf = require('@simpleworkjs/conf');
|
||||||
|
|
||||||
const letsEncrypt = new LetsEncrypt({
|
const letsEncrypt = new LetsEncrypt({
|
||||||
directoryUrl: conf.environment === "production" ?
|
directoryUrl: conf.environment === "production" ?
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
const conf = require('../conf');
|
const conf = require('@simpleworkjs/conf');
|
||||||
|
|
||||||
const User = require(`./user_${conf.userModel}`)
|
const User = require(`./user_${conf.userModel}`)
|
||||||
|
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
const { Client, Attribute, Change } = require('ldapts');
|
const { Client, Attribute, Change } = require('ldapts');
|
||||||
const {Token, InviteToken} = require('./token');
|
const {Token, InviteToken} = require('./token');
|
||||||
const conf = require('../conf').ldap;
|
const conf = require('@simpleworkjs/conf').ldap;
|
||||||
|
|
||||||
const client = new Client({
|
const client = new Client({
|
||||||
url: conf.url,
|
url: conf.url,
|
||||||
|
|||||||
Generated
+13
@@ -11,6 +11,7 @@
|
|||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@fortawesome/fontawesome-free": "^7.1.0",
|
"@fortawesome/fontawesome-free": "^7.1.0",
|
||||||
"@popperjs/core": "^2.11.8",
|
"@popperjs/core": "^2.11.8",
|
||||||
|
"@simpleworkjs/conf": "^1.0.0",
|
||||||
"acme-client": "^5.4.0",
|
"acme-client": "^5.4.0",
|
||||||
"axios": "^1.13.2",
|
"axios": "^1.13.2",
|
||||||
"bcrypt": "^6.0.0",
|
"bcrypt": "^6.0.0",
|
||||||
@@ -263,6 +264,18 @@
|
|||||||
"@redis/client": "^5.10.0"
|
"@redis/client": "^5.10.0"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"node_modules/@simpleworkjs/conf": {
|
||||||
|
"version": "1.0.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/@simpleworkjs/conf/-/conf-1.0.0.tgz",
|
||||||
|
"integrity": "sha512-p1dQAELW0oUBRpDoz260TYw18IMI/Y11xYAb17P1MEPjsTAUB0LWE/6ZeA2VQmpU/LXoRnDysg0G/oASGILyUA==",
|
||||||
|
"license": "MIT",
|
||||||
|
"dependencies": {
|
||||||
|
"extend": "^3.0.2"
|
||||||
|
},
|
||||||
|
"engines": {
|
||||||
|
"node": ">=16.0.0"
|
||||||
|
}
|
||||||
|
},
|
||||||
"node_modules/@socket.io/component-emitter": {
|
"node_modules/@socket.io/component-emitter": {
|
||||||
"version": "3.1.2",
|
"version": "3.1.2",
|
||||||
"resolved": "https://registry.npmjs.org/@socket.io/component-emitter/-/component-emitter-3.1.2.tgz",
|
"resolved": "https://registry.npmjs.org/@socket.io/component-emitter/-/component-emitter-3.1.2.tgz",
|
||||||
|
|||||||
@@ -22,6 +22,7 @@
|
|||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@fortawesome/fontawesome-free": "^7.1.0",
|
"@fortawesome/fontawesome-free": "^7.1.0",
|
||||||
"@popperjs/core": "^2.11.8",
|
"@popperjs/core": "^2.11.8",
|
||||||
|
"@simpleworkjs/conf": "^1.0.0",
|
||||||
"acme-client": "^5.4.0",
|
"acme-client": "^5.4.0",
|
||||||
"axios": "^1.13.2",
|
"axios": "^1.13.2",
|
||||||
"bcrypt": "^6.0.0",
|
"bcrypt": "^6.0.0",
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
const router = require('express').Router();
|
const router = require('express').Router();
|
||||||
const conf = require('../conf');
|
const conf = require('@simpleworkjs/conf');
|
||||||
const middleware = require('../middleware/auth');
|
const middleware = require('../middleware/auth');
|
||||||
|
|
||||||
// API routes for authentication.
|
// API routes for authentication.
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
const path = require('path');
|
const path = require('path');
|
||||||
const express = require('express');
|
const express = require('express');
|
||||||
const router = require('express').Router();
|
const router = require('express').Router();
|
||||||
const conf = require('../conf');
|
const conf = require('@simpleworkjs/conf');
|
||||||
|
|
||||||
const values ={
|
const values ={
|
||||||
title: conf.environment !== 'production' ? `dev` : '',
|
title: conf.environment !== 'production' ? `dev` : '',
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
const {Host} = require('../models/host');
|
const {Host} = require('../models/host');
|
||||||
const {SocketServerJson} = require('../utils/unix_socket_json');
|
const {SocketServerJson} = require('../utils/unix_socket_json');
|
||||||
const conf = require('../conf');
|
const conf = require('@simpleworkjs/conf');
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Host Lookup Service
|
* Host Lookup Service
|
||||||
|
|||||||
@@ -113,7 +113,7 @@ if(require.main === module){(async function(){try{
|
|||||||
|
|
||||||
const tldExtract = require('tld-extract').parse_host;
|
const tldExtract = require('tld-extract').parse_host;
|
||||||
const PorkBun = require('./porkbun');
|
const PorkBun = require('./porkbun');
|
||||||
const conf = require('../conf/conf');
|
const conf = require('@simpleworkjs/conf');
|
||||||
|
|
||||||
let porkBun = new PorkBun(conf.porkBun.apiKey, conf.porkBun.secretApiKey);
|
let porkBun = new PorkBun(conf.porkBun.apiKey, conf.porkBun.secretApiKey);
|
||||||
let letsEncrypt = new LetsEncrypt({
|
let letsEncrypt = new LetsEncrypt({
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
const {createClient} = require('redis');
|
const {createClient} = require('redis');
|
||||||
const objValidate = require('../utils/object_validate');
|
const objValidate = require('../utils/object_validate');
|
||||||
const conf = require('../conf');
|
const conf = require('@simpleworkjs/conf');
|
||||||
|
|
||||||
const client = createClient({});
|
const client = createClient({});
|
||||||
client.connect();
|
client.connect();
|
||||||
|
|||||||
Reference in New Issue
Block a user