How to use dotenv-safe - 10 common examples

To help you get started, we’ve selected a few dotenv-safe 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 nicolaschan / bell / scripts / locator.js View on Github external
// Gets a list of all the cities that we get hits from
require('dotenv-safe').config()

const config = {
  postgres: {
    user: process.env.POSTGRES_USER,
    host: process.env.POSTGRES_HOST,
    database: process.env.POSTGRES_DATABASE,
    password: process.env.POSTGRES_PASSWORD,
    port: process.env.POSTGRES_PORT
  }
}
const logger = require('loggy')

if (process.env.POSTGRES_ENABLED !== 'true') {
  logger.error('Postgres is disabled')
  process.exit(1)
}
github zhuowenli / zhuowenli.github.io / app / app.js View on Github external
/*
* @Author: 卓文理
* @Email : 531840344@qq.com
* @Desc  : 主入口
*/
'use strict';

// env
require('dotenv-safe').load();

// koa
const koa = require('koa');
const lodash = require('lodash');
const onerror = require('koa-onerror');
const favicon = require('koa-favicon');
const session = require('koa-session');
const logger = require('./services/logger');
const compose = require('./utils/mw-compose');
const ResponseData = require('./lib/response-data');

// init app, whit proxy
const app = koa();
app.proxy = true;

app.use(session(app));
github 0xTracker / 0x-tracker-worker / src / index.js View on Github external
// Load environment variables from .env in development and throw an
// error if any required variables are missing in production
require('dotenv-safe').config({
  example:
    process.env.NODE_ENV === 'production'
      ? '.env.prod.example'
      : '.env.example',
});

const { logError } = require('./util/error-logger');
const app = require('./app');

app
  .initialise()
  .then(() => app.start())
  .catch(logError);
github keystonejs / keystone / cypress / scripts / utils.js View on Github external
// Inject the prefix onto the keys
  required = Object.keys(required).reduce(
    (memo, requiredKey) =>
      Object.assign(memo, {
        [`${ciEnvPrefix}${requiredKey}`]: required[requiredKey],
      }),
    {}
  );

  // write back to a temporary file
  const tmpobj = tmp.fileSync();
  fs.writeFileSync(tmpobj.fd, envfile.stringifySync(required));

  // Use that temporary file as the 'expected env' vars
  const envVars = dotEnvSafe.config({
    example: tmpobj.name,
  });

  if (envVars.error) {
    // TODO: Better error with info on how to set the correct env vars
    throw new Error(envVars.error);
  }

  // The loaded env vars with the prefix removed
  const loadedEnvVars = Object.keys(envVars.parsed)
    .filter(key => key.startsWith(ciEnvPrefix))
    .reduce(
      (memo, key) =>
        Object.assign(memo, {
          [key.replace(ciEnvPrefix, '')]: envVars.parsed[key],
        }),
github rolodato / gitlab-letsencrypt / test / jekyll.js View on Github external
'use strict';

require('dotenv-safe').load();

const options = {
    staging: true,
    jekyll: true,
    path: '/',
    domain: process.env.GITLAB_LE_JEKYLL_DOMAIN.split(','),
    repository: process.env.GITLAB_LE_JEKYLL_REPOSITORY,
    token: process.env.GITLAB_LE_JEKYLL_TOKEN,
    email: process.env.GITLAB_LE_EMAIL
};

require('../main')(options);
github rolodato / gitlab-letsencrypt / test / index.js View on Github external
'use strict';

require('dotenv-safe').load();

const options = {
    staging: true,
    path: '/public/.well-known/acme-challenge',
    domain: process.env.GITLAB_LE_DOMAIN.split(','),
    repository: process.env.GITLAB_LE_REPOSITORY,
    token: process.env.GITLAB_LE_TOKEN,
    email: process.env.GITLAB_LE_EMAIL
};

require('../main')(options);
github nodejs / i18n / script / status.js View on Github external
#!/usr/bin/env node

const fs = require('fs')
const path = require('path')
const request = require('request')
require('dotenv-safe').load()

const projectKey = process.env.CROWDIN_KEY

const url = `https://api.crowdin.com/api/project/nodejs/status?key=${projectKey}&json`

request.post(url)
  .on('error', err => console.error(err))
  .pipe(fs.createWriteStream(path.join(__dirname, '../stats.json')))
github cdmbase / fullstack-pro / servers / frontend-server / .zenrc.js View on Github external
config.options.devProxy = config.options.ssr;

const extraDefines = {
    __SSR__: config.options.ssr,
    __PERSIST_GQL__: `'${config.options.persistGraphQL}'`,
    __FRONTEND_BUILD_DIR__: `'${config.options.frontendBuildDir}'`,
    __DLL_BUILD_DIR__: `'${config.options.dllBuildDir}'`,
    __DEBUGGING__: `'${debug}'`
};

if (process.env.NODE_ENV !== 'production') {

    if (!config.options.ssr) {
        console.log('Warning! exposing env variables in UI, only run in development.');
        var dotenv = require('dotenv-safe')
            .config(
                {
                    allowEmptyValues: true,
                    path: process.env.ENV_FILE,
                    example: '../../config/development/dev.env',
                });
        const envConfig = {
            plugins: [
                new webpack.DefinePlugin({
                    "__ENV__": JSON.stringify(dotenv.parsed)
                }),
            ],
        }
        config.builders.web.webpackConfig = merge(config.builders.web.webpackConfig, envConfig);
    }
}
github electron / apps / lib / github.js View on Github external
if (!process.env.GH_TOKEN) {
  require('dotenv-safe').load()
}

const Github = require('@octokit/rest')
const github = new Github({

})

github.authenticate({
  type: 'token',
  token: process.env.GH_TOKEN
})

module.exports = github
github 0xTracker / 0x-tracker-worker / jest / setup.js View on Github external
require('dotenv-safe').config({
  example: '.env.test.example',
});

const signale = require('signale');

signale.disable();

dotenv-safe

Load environment variables from .env and ensure they are defined

MIT
Latest version published 19 days ago

Package Health Score

80 / 100
Full package analysis

Popular dotenv-safe functions