本文整理汇总了TypeScript中decentraland-commons.env.load方法的典型用法代码示例。如果您正苦于以下问题:TypeScript env.load方法的具体用法?TypeScript env.load怎么用?TypeScript env.load使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类decentraland-commons.env
的用法示例。
在下文中一共展示了env.load方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: Assertion
import * as chai from 'chai'
import { env } from 'decentraland-commons'
import { omitProps } from './utils'
const Assertion = (chai as any).Assertion // necessary because @types/chai doesn't export chai.Assertion yet
chai.use(require('chai-as-promised'))
env.load({ path: './specs/.env' })
Assertion.addChainableMethod('equalRow', function(expectedRow: any) {
const omittedProps = ['created_at', 'updated_at']
if (!expectedRow.id) {
omittedProps.push('id')
}
const actualRow = omitProps(this._obj, omittedProps)
return new Assertion(expectedRow).to.deep.equal(actualRow)
})
Assertion.addChainableMethod('equalRows', function(expectedRows: any[]) {
const omittedProps = ['created_at', 'updated_at']
if (expectedRows.every(row => !row.id)) {
omittedProps.push('id')
}
const actualRows = this._obj.map(_obj => omitProps(_obj, omittedProps))
return new Assertion(expectedRows).to.deep.equal(actualRows)
示例2: loadEnv
export function loadEnv(envFilePath: string = '../src/.env') {
env.load({ path: resolvePath(envFilePath) })
}
示例3: express
import * as bodyParser from 'body-parser'
import * as express from 'express'
import { env } from 'decentraland-commons'
import { AccountBalanceRouter } from './AccountBalance'
import { OptionRouter } from './Option'
import { PollRouter } from './Poll'
import { ReceiptRouter } from './Receipt'
import { VoteRouter } from './Vote'
import { TokenRouter } from './Token'
import { TranslationRouter } from './Translation'
import { db } from './database'
env.load()
const SERVER_PORT = env.get('SERVER_PORT', 5000)
const app = express()
app.use(bodyParser.urlencoded({ extended: false, limit: '2mb' }))
app.use(bodyParser.json())
if (env.isDevelopment()) {
app.use(function(_, res, next) {
res.setHeader('Access-Control-Allow-Origin', '*')
res.setHeader('Access-Control-Request-Method', '*')
res.setHeader(
'Access-Control-Allow-Methods',
'OPTIONS, GET, POST, PUT, DELETE'
)
res.setHeader('Access-Control-Allow-Headers', 'Content-Type')