当前位置: 首页>>代码示例>>TypeScript>>正文


TypeScript dotenv.load函数代码示例

本文整理汇总了TypeScript中dotenv.load函数的典型用法代码示例。如果您正苦于以下问题:TypeScript load函数的具体用法?TypeScript load怎么用?TypeScript load使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了load函数的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。

示例1: express

import * as dotenv from 'dotenv';
import * as express from 'express';
import * as morgan from 'morgan';
import * as path from 'path';
import * as fs from 'fs';
import * as http from 'http';
import * as https from 'https';
import * as session from 'express-session';

import { SSL, SESSION_STORE } from './config';
import setRoutes from './routes';

const app = express();
const server = http.createServer(app);

dotenv.load({ path: '.env' });
app.set('port', (process.env.PORT || 3000));

app.use('/', express.static(path.join(__dirname, '../public')));
app.use(bodyParser.json());
app.use(bodyParser.urlencoded({ extended: true }));
app.use(session({
  store: SESSION_STORE,
  secret: 'helix',
  resave: true,
  saveUninitialized: true,
  cookie: { expires: new Date(2147483647000) }
}));

app.use(morgan('dev'));
开发者ID:apache,项目名称:helix,代码行数:30,代码来源:app.ts

示例2: require

ďťż/// <reference path="./.types/node/node.d.ts" />

// load environment variables from a .env file, if it exists
var dotenv = require('dotenv');
dotenv.load();

import http = require('http');
import app = require('./src/app');
var log = require('./src/log');

var environment = process.env.NODE_ENV || 'development';

if (environment == 'production') {
  // New Relic
  require('newrelic');
  // Logentries
  var winston = require('winston');
  var logentries = require('node-logentries');
  logentries.logger({
    token: process.env.LOGENTRIES_TOKEN
  }).winston(winston, {});
  log.add(winston.transports.LogentriesLogger);
}

log.info('Running in environment ' + environment);

var appOpts = {
  environment: environment,
  port: process.env.PORT || 3000,
  dbType: 'mongodb',
  mongoUrl: process.env.MONGO_URL || 'mongodb://127.0.0.1:27017/valtech-shortie?w=1',
开发者ID:valtech,项目名称:valtech-shortie,代码行数:31,代码来源:server.ts


注:本文中的dotenv.load函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。