本文整理汇总了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'));
示例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',