How to use simple-configure - 10 common examples

To help you get started, we’ve selected a few simple-configure 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 softwerkskammer / Agora / softwerkskammer / lib / wiki / gitExec.js View on Github external
const Path = require('path');
const ChildProcess = require('child_process');
const Fs = require('fs');

const conf = require('simple-configure');

let gitCommands = [];
let workTree = conf.get('wikipath');

if (workTree) {
  Fs.realpath(workTree, (err, absWorkTree) => {
      if (err) { throw new Error('Repository path does not exist: ' + workTree); }
      workTree = absWorkTree;
      const gitDir = Path.join(workTree, '.git');
      Fs.stat(gitDir, (err1) => {
        if (err1) { throw new Error('Repository path is not initialized: ' + workTree); }
        gitCommands = ['--git-dir=' + gitDir, '--work-tree=' + workTree];
        // run a smoke test of git and the repo:
        ChildProcess.exec('git log -1 --oneline ', {cwd: workTree}, (err2) => {
          if (err2) {
            if (/fatal: your current branch 'master' does not have any commits yet/.test(err2.message)) {
              throw new Error('Please add an initial commit to the repository: ' + workTree);
            }
            throw new Error(err2.message + ' in ' + workTree);
github softwerkskammer / Agora / softwerkskammer / lib / notifications / index.js View on Github external
function addPrettyAndUrlTo(object) {
  object.pretty = true; // makes the generated html nicer, in case someone looks at the mail body
  object.url = conf.get('publicUrlPrefix');
}
github softwerkskammer / Agora / socrates / lib / middleware / secureSoCraTesAdminOnly.js View on Github external
module.exports = function redirectIfNotSoCraTesAdmin(req, res, next) {
  const originalUrl = req.originalUrl;
  const user = req.user;

  if (securedBySoCraTesAdminURLRegex && securedBySoCraTesAdminURLRegex.test(originalUrl)) {
    if (!res.locals.accessrights.isSoCraTesAdmin()) {
      logger.info('Someone tried to access SoCraTes-Admin protected page ' + originalUrl + ' ' + (user ? ' - User was: ' + user.authenticationId : ''));
      return res.redirect('/mustBeSoCraTesAdmin?page=' + encodeURIComponent(conf.get('publicUrlPrefix') + originalUrl));
    }
  }
  next();
};
github softwerkskammer / Agora / softwerkskammer / lib / middleware / secureSuperuserOnly.js View on Github external
module.exports = function redirectIfNotSuperuser(req, res, next) {
  const originalUrl = req.originalUrl;
  const user = req.user;

  if (securedBySuperuserURLRegex.test(originalUrl)) {
    if (!res.locals.accessrights.isSuperuser()) {
      logger.info('Someone tried to access superuser protected page ' + originalUrl + ' ' + (user ? ' - User was: ' + user.authenticationId : ''));
      return res.redirect('/mustBeSuperuser?page=' + encodeURIComponent(conf.get('publicUrlPrefix') + originalUrl));
    }
  }
  next();
};
github softwerkskammer / Agora / softwerkskammer / lib / dashboard / index.js View on Github external
const beans = require('simple-configure').get('beans');
const misc = beans.get('misc');
const dashboardService = beans.get('dashboardService');

const app = misc.expressAppIn(__dirname);

app.get('/', (req, res, next) => {
  dashboardService.dataForDashboard(req.user.member.nickname(), (err, result) => {
    if (err) { return next(err); }
    res.render('index', result);
  });
});

module.exports = app;
github softwerkskammer / Agora / socrates / lib / subscribers / index.js View on Github external
'use strict';
const beans = require('simple-configure').get('beans');
const misc = beans.get('misc');
const subscriberstore = beans.get('subscriberstore');

const app = misc.expressAppIn(__dirname);

app.get('/count', (req, res) => {
  subscriberstore.allSubscribers((err, subscribers) => {
    if (err || !subscribers) { return res.end(''); }
    res.end(subscribers.length.toString());
  });
});

module.exports = app;
github softwerkskammer / Agora / softwerkskammer / lib / groups / groupMapper.js View on Github external
const conf = require('simple-configure');
const beans = conf.get('beans');
const Group = beans.get('group');

module.exports = {
  bodyToGroup: function (body) {
    const override = {
      contactTheOrganizers: body.contactTheOrganizers ? body.contactTheOrganizers === 'on' : false
    };
    const mapped = Object.assign({}, body, override);
    return new Group(mapped);
  }
};
github softwerkskammer / Agora / softwerkskammer / lib / middleware / announcementsInSidebar.js View on Github external
'use strict';

var store = require('simple-configure').get('beans').get('announcementstore');
var _ = require('lodash');

module.exports = function latestNews(req, res, next) {
  store.allAnnouncementsUntilToday(function (err, news) {
    if (err) {return next(err); }
    var maxNewsInSidebar = 5;
    res.locals.latestNews = _.take(news, maxNewsInSidebar);
    res.locals.displayMoreNews = news.length > maxNewsInSidebar;
    next();
  });
};
github softwerkskammer / Agora / socrates / lib / middleware / wikiSubdirs.js View on Github external
'use strict';

const Git = require('simple-configure').get('beans').get('gitmech');

module.exports = function subdirs(req, res, next) {
  Git.lsdirs((err, gitdirs) => {
    res.locals.wikisubdirs = gitdirs;
    next(err);
  });
};
github softwerkskammer / Agora / softwerkskammer / lib / members / member.js View on Github external
static isSuperuser(id) {
    const superusers = conf.get('superuser');
    return superusers && superusers.indexOf(id) > -1;
  }

simple-configure

A simple node.js configuration management module

MIT
Latest version published 10 years ago

Package Health Score

42 / 100
Full package analysis

Popular simple-configure functions