Cloud Defense Logo

Products

Solutions

Company

Book A Live Demo

Top 10 Examples of "dotenv-safe in functional component" in JavaScript

Dive into secure and efficient coding practices with our curated list of the top 10 examples showcasing 'dotenv-safe' in functional components in JavaScript. Our advanced machine learning engine meticulously scans each line of code, cross-referencing millions of open source libraries to ensure your implementation is not just functional, but also robust and secure. Elevate your React applications to new heights by mastering the art of handling side effects, API calls, and asynchronous operations with confidence and precision.

// 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)
}
/*
* @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));
// 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);
// 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],
        }),
'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);
'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);
#!/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')))
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);
    }
}
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
require('dotenv-safe').config({
  example: '.env.test.example',
});

const signale = require('signale');

signale.disable();

Is your System Free of Underlying Vulnerabilities?
Find Out Now