Browse Source

Fix: exporting env ENABLE_NPM_FAILOVER=false will not work unless we parse the string

pull/4/head
Harish.K 9 years ago
parent
commit
cfcb8b0feb
  1. 8
      app.js

8
app.js

@ -39,7 +39,8 @@ app.get( '/:package', function( req, res, next ){
.tap( function( isExists ){ .tap( function( isExists ){
if( !isExists ){ if( !isExists ){
if ( !ENABLE_NPM_FAILOVER ) { if ( !ENABLE_NPM_FAILOVER ) {
return Promise.reject( { status:404, message: 'Package not found' });
res._log.cacheHit = '!!!';
return Promise.reject( { status:404, message: {}});
} }
res._log.cacheHit = '---'; res._log.cacheHit = '---';
return fetchAndCacheMetadata( packageName, cacheFile ); return fetchAndCacheMetadata( packageName, cacheFile );
@ -66,7 +67,8 @@ app.get( '/:package/-/:tarball', function( req, res, next ){
.tap( function( isExists ){ .tap( function( isExists ){
if( !isExists ){ if( !isExists ){
if ( !ENABLE_NPM_FAILOVER ) { if ( !ENABLE_NPM_FAILOVER ) {
return Promise.reject( { status: 404, message: '' });
res._log.cacheHit = '!!!';
return Promise.reject( { status: 404, message: {} });
} }
res._log.cacheHit = '---'; res._log.cacheHit = '---';
return fetchAndCacheTarball( packageName, version, packagePath ); return fetchAndCacheTarball( packageName, version, packagePath );
@ -90,7 +92,7 @@ app.use(function(req, res, next) {
// error handlers // error handlers
app.use(function(err, req, res, next) { app.use(function(err, req, res, next) {
console.log( err.stack );
err.stack && console.log( err.stack );
res.status(err.status || 500); res.status(err.status || 500);
res.send( err.message || err ); res.send( err.message || err );
if( next ) { next(); } if( next ) { next(); }

Loading…
Cancel
Save