當前位置: 首頁>>代碼示例>>TypeScript>>正文


TypeScript nconf.file函數代碼示例

本文整理匯總了TypeScript中nconf.file函數的典型用法代碼示例。如果您正苦於以下問題:TypeScript file函數的具體用法?TypeScript file怎麽用?TypeScript file使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。


在下文中一共展示了file函數的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。

示例1: start

async function start() {
    const server = new Hapi.Server();

    const env = process.env.NODE_ENV || 'development';
    process.env.NODE_ENV = env; //So the plugins load right
    const configFilePath = path.join(__dirname, "config", env + ".json");
    const userConfigFilePath = path.join(__dirname, "config", env + ".user.json");
    nconf
        .file("user_overrides", userConfigFilePath)
        .file("defaults", configFilePath);

    server.connection({
        host: nconf.get('hapi:host'),
        port: nconf.get('hapi:port')
    });

    const appLogger = new AppLogger();
    server.app.logger = await appLogger.initialize(nconf);

    await Plugin.registerAll(server, nconf);
    await Api.loadRoutes(server);

    await server.start();
    if (server.info !== null) {
        server.app.logger.info(`Server running at ${server.info.uri}`);
    }
}
開發者ID:dangelspencer,項目名稱:typed-hapi,代碼行數:27,代碼來源: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: saveGpioSchedule

export function saveGpioSchedule(bcmPinNumber: number, encodedSchedule: number) {
    nconf.file({
        file: fileName
    });

    const key = 'gpio:' + bcmPinNumber + ':encodedSchedule';
    nconf.set(key, encodedSchedule);
    nconf.save(function (error) {
        if (error) {
            console.error('error:' + error);
        } else {
            console.log('saved schedule ' + key + ', value: ' + encodedSchedule);
        }
    });
}
開發者ID:kaga,項目名稱:Home-Sensor,代碼行數:15,代碼來源:configurationManager.ts

示例4: 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

示例5: loadConfiguration

export function loadConfiguration() {
    nconf.file({
        file: fileName
    });

    const gpioConfigs = nconf.get('gpio');
    const mockGpio = nconf.get('mock_gpio');

    console.log('reading gpio configs, useMock:' + mockGpio);
    console.log(JSON.stringify(gpioConfigs, null, 4));

    return {
        useMock: mockGpio,
        configs: validateGpioConfigurations(gpioConfigs)
    };
}
開發者ID:kaga,項目名稱:Home-Sensor,代碼行數:16,代碼來源:configurationManager.ts

示例6: 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

示例7:

/**
 * Application configuration
 *
 * Configuration is sourced from the following places, in order of
 * precedence:
 *
 * - Environment variables
 * - JSON file named after NODE_ENV
 * - JSON file named config.json
 * - JSON file in /etc
 * - 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'),
});
開發者ID:lovett,項目名稱:notifier,代碼行數:31,代碼來源:server.ts


注:本文中的nconf.file函數示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。