Merge pull request #86 from theta42/conf

Using the simpleworks conf now
This commit is contained in:
2025-12-31 19:30:12 -05:00
committed by GitHub
15 changed files with 27 additions and 44 deletions
+1 -1
View File
@@ -7,7 +7,7 @@
var app = require('../app');
var debug = require('debug')('proxy-api:server');
var http = require('http');
const conf = require('../conf');
const conf = require('@simpleworkjs/conf');
/**
* Get port from environment and store in Express.
+1
View File
@@ -1,4 +1,5 @@
'use strict';
// Using https://github.com/simpleworkjs/conf to handle configuration
module.exports = {
userModel: 'redis', // pam, redis, ldap
-32
View File
@@ -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}
);
+1 -1
View File
@@ -2,7 +2,7 @@
const {createClient} = require('redis');
const objValidate = require('../utils/object_validate');
const conf = require('../conf/conf');
const conf = require('@simpleworkjs/conf');
const client = createClient({});
+2 -2
View File
@@ -2,7 +2,7 @@
const crypto = require("crypto");
const conf = require('../conf');
const conf = require('@simpleworkjs/conf');
const Table = require('../utils/redis_model');
const ModelPs = require('../utils/model_pubsub');
@@ -178,7 +178,7 @@ DnsProvider.register(ModelPs(DnsProvider))
if(require.main === module){(async function(){try{
const conf = require('../conf');
const conf = require('@simpleworkjs/conf');
// console.log(await DnsProvider.findall());
+1 -1
View File
@@ -6,7 +6,7 @@ const ModelPs = require('../utils/model_pubsub');
const tldExtract = require('tld-extract').parse_host;
const LetsEncrypt = require('../utils/letsencrypt');
const conf = require('../conf');
const conf = require('@simpleworkjs/conf');
const letsEncrypt = new LetsEncrypt({
directoryUrl: conf.environment === "production" ?
+1 -1
View File
@@ -1,6 +1,6 @@
'use strict';
const conf = require('../conf');
const conf = require('@simpleworkjs/conf');
const User = require(`./user_${conf.userModel}`)
+1 -1
View File
@@ -2,7 +2,7 @@
const { Client, Attribute, Change } = require('ldapts');
const {Token, InviteToken} = require('./token');
const conf = require('../conf').ldap;
const conf = require('@simpleworkjs/conf').ldap;
const client = new Client({
url: conf.url,
+13
View File
@@ -11,6 +11,7 @@
"dependencies": {
"@fortawesome/fontawesome-free": "^7.1.0",
"@popperjs/core": "^2.11.8",
"@simpleworkjs/conf": "^1.0.0",
"acme-client": "^5.4.0",
"axios": "^1.13.2",
"bcrypt": "^6.0.0",
@@ -263,6 +264,18 @@
"@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": {
"version": "3.1.2",
"resolved": "https://registry.npmjs.org/@socket.io/component-emitter/-/component-emitter-3.1.2.tgz",
+1
View File
@@ -22,6 +22,7 @@
"dependencies": {
"@fortawesome/fontawesome-free": "^7.1.0",
"@popperjs/core": "^2.11.8",
"@simpleworkjs/conf": "^1.0.0",
"acme-client": "^5.4.0",
"axios": "^1.13.2",
"bcrypt": "^6.0.0",
+1 -1
View File
@@ -1,7 +1,7 @@
'use strict';
const router = require('express').Router();
const conf = require('../conf');
const conf = require('@simpleworkjs/conf');
const middleware = require('../middleware/auth');
// API routes for authentication.
+1 -1
View File
@@ -3,7 +3,7 @@
const path = require('path');
const express = require('express');
const router = require('express').Router();
const conf = require('../conf');
const conf = require('@simpleworkjs/conf');
const values ={
title: conf.environment !== 'production' ? `dev` : '',
+1 -1
View File
@@ -2,7 +2,7 @@
const {Host} = require('../models/host');
const {SocketServerJson} = require('../utils/unix_socket_json');
const conf = require('../conf');
const conf = require('@simpleworkjs/conf');
/**
* Host Lookup Service
+1 -1
View File
@@ -113,7 +113,7 @@ if(require.main === module){(async function(){try{
const tldExtract = require('tld-extract').parse_host;
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 letsEncrypt = new LetsEncrypt({
+1 -1
View File
@@ -2,7 +2,7 @@
const {createClient} = require('redis');
const objValidate = require('../utils/object_validate');
const conf = require('../conf');
const conf = require('@simpleworkjs/conf');
const client = createClient({});
client.connect();