当前位置: 首页>>代码示例>>TypeScript>>正文


TypeScript nconf.defaults函数代码示例

本文整理汇总了TypeScript中nconf.defaults函数的典型用法代码示例。如果您正苦于以下问题:TypeScript defaults函数的具体用法?TypeScript defaults怎么用?TypeScript defaults使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了defaults函数的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。

示例1: Run

function Run(): void {
    // #1 Command-line arguments
    nconf.argv();
    // #2 Environment variables
    nconf.env();
    // #3 A file located at '{.}config.json'
    nconf.file({
        file: "./config.json"
    });
    // #4 Defaults
    // default name for Azure Store Table
    nconf.defaults({
        "Azure:Store:TableName": "table-name"
    });
    console.log(JSON.stringify(nconf.get(null), null, "\t"));
}
开发者ID:samelamin,项目名称:azure-nodejs-examples,代码行数:16,代码来源:index.ts

示例2: constructor

  constructor() {
    nconf
      .argv()
      .env({
        separator: '__'
      });

    nconf.defaults({
      'NODE_ENV': 'development'
    });

    const environment = nconf.get('NODE_ENV');
    const configDir = path.join(__dirname, '..', '..', '..', '..', 'config');

    nconf.file(environment, path.join(configDir, `${environment}.json`));
    nconf.file('default', path.join(configDir, 'default.json'));
  }
开发者ID:vmlf01,项目名称:ts-painters-node,代码行数:17,代码来源:Config.ts

示例3: require

const nunjucks = require('nunjucks');
const cookieParser = require('cookie-parser');
const favicon = require('serve-favicon');
const nconf = require('nconf');

// Setup nconf to use (in-order):
//   1. Command-line arguments
//   2. Environment variables
//   3. A file located at './config.json'
nconf.argv().env().file({ file: './config.json' });
nconf.defaults({
  'NODE_ENV': 'development',
  'NODE_PATH': '.',
  'PORT': 3000,

  // custom flags
  'appName': 'NodeExample',
  'logLevel': 'warn',
  'logInJson': false,
  'lang': 'en-US'
});

// Environment variables
const ROOT: string = nconf.get('NODE_PATH');
const ENV: string = nconf.get('NODE_ENV');
const PORT: string = nconf.get('PORT');

// Helper variables
const isDev: Boolean = ENV === 'development';
const lang: string = nconf.get('lang');
const srcPath: string = `${ROOT}/src/`;
开发者ID:melxx001,项目名称:simple-nodejs-typescript-starter,代码行数:31,代码来源:server.ts

示例4: Promise

import * as fs from "fs";
import * as nconf from "nconf";
import {defaults} from "./defaults";
import * as configs from "./env";

/**
 * Create app configuration
 */
export var config = {
    // environment specific options
    for: (env) => {
        env = env.toLowerCase().trim();
        return new Promise((resolve, reject) => {
            nconf.overrides(configs[env]);             
            // do some async stuff if needed           
            resolve();
        });
    },
    // not chengable options
    get configure() {
        nconf.argv().env();
        nconf.defaults(defaults);
        nconf.file("app", {
            file: 'config.json',
            dir: __dirname,
            search: true
        });
        return this;
    }
};  
开发者ID:cm0s,项目名称:mea2n,代码行数:30,代码来源:config.ts

示例5: require

ďťżvar file = require("file");
var fileExists = require('file-exists');
var fs = require("fs");
var nconf = require('nconf');


nconf.argv().env().file({ file: './config.json' });
nconf.defaults({
    "metadata": { "path": "./metadata" }
});


var rules = [];
var types = {};

//common.person.
var race = {};
var origin = {};
var ethnicity = {};


var metadatPath = file.path.abspath(nconf.get('metadata:path'));
file.walkSync(metadatPath, (dirPath, dirs, files) => {

    for (var i = 0; i < files.length; i++) {
        var filePath = file.path.join(dirPath, files[i]);

        if (fileExists(filePath)) {
            console.log('loading metadata from ' + filePath);

开发者ID:ttrider,项目名称:Melichrone,代码行数:29,代码来源:app.ts

示例6: express

 * - Internal defaults
 */

nconf.env();

nconf.file('environment', path.join(__dirname, '../../', 'config-' + process.env.NODE_ENV + '.json'));

nconf.file('application', path.join(__dirname, '../../', 'config.json'));

nconf.file('host', '/etc/notifier.json');

nconf.defaults({
    NOTIFIER_APP_DIR: path.resolve('./app'),
    NOTIFIER_BADGE_BASE_URL: '/svg',
    NOTIFIER_BASE_URL: '/',
    NOTIFIER_DB_DSN: 'postgres://notifier:notifier@localhost:5432/notifier',
    NOTIFIER_FORCE_HTTPS: 0,
    NOTIFIER_HTTP_IP: '127.0.0.1',
    NOTIFIER_HTTP_PORT: 8080,
    NOTIFIER_PUBLIC_DIR: path.resolve('./public'),
});

app = express();

app.disable('x-powered-by');

app.locals.config = nconf;

app.locals.protected = passport.authenticate(['cookie', 'basic', 'local'], { session: false });

app.locals.pushClients = {};
开发者ID:lovett,项目名称:notifier,代码行数:31,代码来源:server.ts


注:本文中的nconf.defaults函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。