本文整理汇总了TypeScript中config.util.getEnv方法的典型用法代码示例。如果您正苦于以下问题:TypeScript util.getEnv方法的具体用法?TypeScript util.getEnv怎么用?TypeScript util.getEnv使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类config.util
的用法示例。
在下文中一共展示了util.getEnv方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: convert
Object.keys(current).forEach(name => {
let value = current[name];
if (typeof value === 'object' && value !== null) {
value = convert(value);
}
if (typeof value === 'string') {
if (value.indexOf('\\') === 0) {
value = value.replace('\\', '');
} else {
if (process.env[value]) {
value = process.env[value];
} else if (value.indexOf('.') === 0 || value.indexOf('..') === 0) {
// Make relative paths absolute
value = path.resolve(
path.join(config.util.getEnv('NODE_CONFIG_DIR')),
value.replace(/\//g, separator)
);
}
}
}
result[name] = value;
});
示例2: checkActivityPubUrls
async function checkActivityPubUrls () {
const actor = await getServerActor()
const parsed = parse(actor.url)
if (CONFIG.WEBSERVER.HOST !== parsed.host) {
const NODE_ENV = config.util.getEnv('NODE_ENV')
const NODE_CONFIG_DIR = config.util.getEnv('NODE_CONFIG_DIR')
logger.warn(
'It seems PeerTube was started (and created some data) with another domain name. ' +
'This means you will not be able to federate! ' +
'Please use %s %s npm run update-host to fix this.',
NODE_CONFIG_DIR ? `NODE_CONFIG_DIR=${NODE_CONFIG_DIR}` : '',
NODE_ENV ? `NODE_ENV=${NODE_ENV}` : ''
)
}
}
示例3: return
return (app: Application|undefined) => {
const convert = (current: any) => {
const result: { [key: string]: any } = Array.isArray(current) ? [] : {};
Object.keys(current).forEach(name => {
let value = current[name];
if (typeof value === 'object' && value !== null) {
value = convert(value);
}
if (typeof value === 'string') {
if (value.indexOf('\\') === 0) {
value = value.replace('\\', '');
} else {
if (process.env[value]) {
value = process.env[value];
} else if (value.indexOf('.') === 0 || value.indexOf('..') === 0) {
// Make relative paths absolute
value = path.resolve(
path.join(config.util.getEnv('NODE_CONFIG_DIR')),
value.replace(/\//g, separator)
);
}
}
}
result[name] = value;
});
return result;
};
const env = config.util.getEnv('NODE_ENV');
const conf = convert(config);
if (!app) {
return conf;
}
debug(`Initializing configuration for ${env} environment`);
Object.keys(conf).forEach(name => {
const value = conf[name];
debug(`Setting ${name} configuration value to`, value);
(app as Application).set(name, value);
});
return conf;
};
示例4:
import * as config from "config";
var class1: config.IConfig = config;
var value1: string = config.get<string>("");
var value2: any = config.get("");
var has: boolean = config.has("");
// util tests:
var extended1: any = config.util.extendDeep({}, {});
var extended2: any = config.util.extendDeep({}, {}, 20);
var clone1: any = config.util.cloneDeep({});
var clone2: any = config.util.cloneDeep({}, 20);
var equals1: boolean = config.util.equalsDeep({}, {});
var equals2: boolean = config.util.equalsDeep({}, {}, 20);
var diff1: any = config.util.diffDeep({}, {});
var diff2: any = config.util.diffDeep({}, {}, 20);
var immutable1: any = config.util.makeImmutable({});
var immutable2: any = config.util.makeImmutable({}, "");
var immutable3: any = config.util.makeImmutable({}, "", "");
var hidden1: any = config.util.makeHidden({}, "");
var hidden2: any = config.util.makeHidden({}, "", "");
var env: string = config.util.getEnv("");
示例5: function
import * as winston from 'winston';
import * as config from 'config';
export const logger = new winston.Logger();
const env = config.util.getEnv('NODE_ENV');
// Development Logger
if(env === 'development') {
logger.add(winston.transports.Console, {
type: 'verbose',
colorize: true,
prettyPrint: true,
handleExceptions: true,
humanReadableUnhandledException: true
});
}
process.on('unhandledRejection', function (reason, p) {
logger.warn('Possibly Unhandled Rejection at: Promise ', p, ' reason: ', reason);
});