How to use node-yaml-config - 10 common examples

To help you get started, we’ve selected a few node-yaml-config examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github spmjs / spmjs.io / scripts / fixGithubLoginToId.js View on Github external
// 把所有包的 owners 和 publisher 字段
// 替换为 { name: 'xx', id: 12 } 这样的对象
// 修复 https://github.com/spmjs/spmjs.io/issues/101
// ---
var async = require('async');

// load global config
var yaml = require('node-yaml-config');
var CONFIG = yaml.load('./config/base.yaml');
global.CONFIG = CONFIG;

var models = require('../models');
var Project = require('../models/project');
var Package = require('../models/package');

Project.getAll().forEach(function(projectName) {
  console.log('Start fixing ' + projectName);
  var project = new Project({
    name: projectName
  });

  var tasks = [];
  project.owners.forEach(function(ownerName, i) {
    if (ownerName && typeof ownerName === 'string') {
      tasks.push(function(callback) {
github spmjs / spmjs.io / lib / cacheIndexWorker.js View on Github external
'use strict';

// load global config
var yaml = require('node-yaml-config');
var CONFIG = yaml.load('./config/base.yaml');
global.CONFIG = CONFIG;

var async = require('async');
var models = require('../models');
var dependent = require('../lib/dependent');
var anonymous = CONFIG.authorize.type === 'anonymous';

process.on('message', function(m) {

  function doCache(done) {
    console.log('cacheIndexWorker: do cache for index');
    async.parallel([
      function(callback) {
        models.Download.stat(function(downloadResult) {
          callback(null, downloadResult);
        });
github daylen / elevate / app.js View on Github external
var express = require('express');
var path = require('path');
var favicon = require('serve-favicon');
var logger = require('morgan');
var compression = require('compression')
var cookieParser = require('cookie-parser');
var bodyParser = require('body-parser');
globalConfig = require('node-yaml-config').load(__dirname + '/config/custom.yml');

var mongoose = require('mongoose');
mongoose.connect(globalConfig.mongodb_url);

var api = require('./routes/api');
var admin = require('./routes/admin');

var app = express();

if (process.env.NODE_ENV == 'dev') {
  console.log('DEV MODE ENABLED');
} else {
  require('./connectors').enableBackgroundCrawl();
}

// view engine setup
github spmjs / spmjs.io / app.js View on Github external
var path = require('path');
var multipart = require('connect-multiparty');
var multipartMiddleware = multipart();
var favicon = require('serve-favicon');
var morgan = require('morgan');
var bodyParser = require('body-parser');
var cookieParser = require('cookie-parser');
var session = require('express-session');
var serveStatic = require('serve-static');
var fs = require('fs-extra');
var spmjsioVersion = require('./package').version;
var gitRev = require('git-rev-sync').short();

// load global config
var yaml = require('node-yaml-config');
var CONFIG = yaml.load('./config/base.yaml');
global.CONFIG = CONFIG;

// start sync
require('./sync');

// mkdir data directory
if (!fs.existsSync(CONFIG.wwwroot)) {
  fs.mkdirSync(CONFIG.wwwroot);
}
if (!fs.existsSync(path.join(CONFIG.wwwroot, 'db'))) {
  fs.mkdirSync(path.join(CONFIG.wwwroot, 'db'));
}
if (!fs.existsSync(path.join(CONFIG.wwwroot, 'docs'))) {
  fs.mkdirSync(path.join(CONFIG.wwwroot, 'docs'));
}
if (!fs.existsSync(path.join(CONFIG.wwwroot, 'repository'))) {
github spmjs / spmjs.io / sync-from-npm / _index.js View on Github external
'use strict';

var path = require('path');
var join = path.join;

// load global config
var yaml = require('node-yaml-config');
var CONFIG = yaml.load(join(__dirname, '../config/base.yaml'));
global.CONFIG = CONFIG;

var registry = CONFIG.npmSyncRegistry || 'registry.npmjs.org';

var hook = require('../lib/hook');

var request = require('co-request');
var semver = require('semver');
var co = require('co');
var log = require('spm-log');
var format = require('util').format;
var extend = require('extend');
var thunkify = require('thunkify');
var crypto = require('crypto');
var clientTar = require('spm-client').tar;
var moment = require('moment');
github spmjs / spmjs.io / scripts / upgradeToMysql.js View on Github external
'use strict';

var yaml = require('node-yaml-config');
var CONFIG = yaml.load('./config/base.yaml');
global.CONFIG = CONFIG;

var models = require('../models/index');

models.sequelize.sync().then(function() {
  require('async').series([
    function(next) { return transform('Account', next) },
    function(next) { return transform('Download', next) },
    function(next) { return transform('History', next) }
  ], function() {
    console.log('done');
  });
});

function transform(type, done) {
  console.log('transform', type.toLowerCase());
github brianseitel / node-wars / core / bigbang.js View on Github external
var config   = require('node-yaml-config').load('./config/game.yml');
var fs       = require('fs');

var Cluster  = require('../models/cluster');
var Helper   = require('../core/helpers');
var Sector   = require('../models/sector');
var Shop     = require('../models/shop');
var Trader   = require('../models/trader');
var Universe = require('../models/universe');

var BigBang = function() {
    this.universe = new Universe;
};

BigBang.prototype.start = function() {
    this.initializeSectors();
    this.initializeClusters();
github brianseitel / node-wars / models / trader.js View on Github external
var config   = require('node-yaml-config').load('./config/game.yml');

var Trader = function() {
    this.name    = null;
    this.sector  = 1;
    this.level   = 1;
    this.credits = 0;
    this.ship    = null;
    this.holds   = 100;
    this.cargo   = { 
        fuel      : 0,
        organics  : 0,
        equipment : 0
    };

};
github brianseitel / node-wars / models / shop.js View on Github external
var config       = require('node-yaml-config').load('./config/game.yml');
var util         = require('util');
var EventEmitter = require('events').EventEmitter;

var Shop = function(id, emitter) {
    this.id     = id;
    this.sector = null;
    this.bank   = 0;
    this.type   = 1;
    this.prices = {
        fuel     : 10,
        organics : 10,
        equipment: 10,
    };

    this.inventory = {
        fuel     : 100,
github asyncapi / generator / templates / nodejs / src / lib / config.js View on Github external
const path = require('path');
const YAMLConfig = require('node-yaml-config');
const dotenv = require('dotenv');
const config = YAMLConfig.load(path.join(__dirname, '../../config/common.yml'));
const env = process.env;
dotenv.config();
overrideWithEnvVars(config);

/**
 * Overrides a config object with the values from environment variables, if found.
 *
 * @param {Object} cfg Config object
 * @param {String} prefix Key prefix
 */
function overrideWithEnvVars(cfg, prefix) {
  prefix = prefix || '';
  for (const key in cfg) {
    const fullKey = prefix + key.toUpperCase();

    if (typeof cfg[key] === 'object' && !Array.isArray(cfg[key]) && cfg[key] !== null) {

node-yaml-config

Write your configuration files for node.js in yaml

MIT
Latest version published 3 years ago

Package Health Score

47 / 100
Full package analysis

Popular node-yaml-config functions