Skip invariants in test env
This commit is contained in:
parent
293786d182
commit
f4f0c59552
|
@ -1,5 +1,5 @@
|
||||||
require('isomorphic-fetch')
|
require('isomorphic-fetch')
|
||||||
const warning = require('warning')
|
const invariant = require('invariant')
|
||||||
const gunzip = require('gunzip-maybe')
|
const gunzip = require('gunzip-maybe')
|
||||||
const ndjson = require('ndjson')
|
const ndjson = require('ndjson')
|
||||||
|
|
||||||
|
@ -7,12 +7,12 @@ const CloudflareAPIURL = 'https://api.cloudflare.com'
|
||||||
const CloudflareEmail = process.env.CLOUDFLARE_EMAIL
|
const CloudflareEmail = process.env.CLOUDFLARE_EMAIL
|
||||||
const CloudflareKey = process.env.CLOUDFLARE_KEY
|
const CloudflareKey = process.env.CLOUDFLARE_KEY
|
||||||
|
|
||||||
warning(
|
invariant(
|
||||||
CloudflareEmail,
|
CloudflareEmail,
|
||||||
'Missing the $CLOUDFLARE_EMAIL environment variable'
|
'Missing the $CLOUDFLARE_EMAIL environment variable'
|
||||||
)
|
)
|
||||||
|
|
||||||
warning(
|
invariant(
|
||||||
CloudflareKey,
|
CloudflareKey,
|
||||||
'Missing the $CLOUDFLARE_KEY environment variable'
|
'Missing the $CLOUDFLARE_KEY environment variable'
|
||||||
)
|
)
|
||||||
|
|
|
@ -9,9 +9,6 @@ const packageURL = require('./middleware/packageURL')
|
||||||
const fetchFile = require('./middleware/fetchFile')
|
const fetchFile = require('./middleware/fetchFile')
|
||||||
const serveFile = require('./middleware/serveFile')
|
const serveFile = require('./middleware/serveFile')
|
||||||
|
|
||||||
const createSearchServer = require('./createSearchServer')
|
|
||||||
const createStatsServer = require('./createStatsServer')
|
|
||||||
|
|
||||||
morgan.token('fwd', function (req) {
|
morgan.token('fwd', function (req) {
|
||||||
return req.get('x-forwarded-for').replace(/\s/g, '')
|
return req.get('x-forwarded-for').replace(/\s/g, '')
|
||||||
})
|
})
|
||||||
|
@ -48,8 +45,13 @@ function createApp() {
|
||||||
maxAge: '365d'
|
maxAge: '365d'
|
||||||
}))
|
}))
|
||||||
|
|
||||||
app.use('/_search', createSearchServer())
|
if (process.env.NODE_ENV !== 'test') {
|
||||||
app.use('/_stats', createStatsServer())
|
const createSearchServer = require('./createSearchServer')
|
||||||
|
app.use('/_search', createSearchServer())
|
||||||
|
|
||||||
|
const createStatsServer = require('./createStatsServer')
|
||||||
|
app.use('/_stats', createStatsServer())
|
||||||
|
}
|
||||||
|
|
||||||
app.use('/',
|
app.use('/',
|
||||||
packageURL,
|
packageURL,
|
||||||
|
|
Loading…
Reference in New Issue