mirror of
https://github.com/harish2704/npm-offline-registry.git
synced 2026-09-10 06:21:09 +00:00
Small Cleanup
This commit is contained in:
@@ -40,7 +40,7 @@ app.get( '/:package', function( req, res, next ){
|
|||||||
if( !isExists ){
|
if( !isExists ){
|
||||||
if ( !ENABLE_NPM_FAILOVER ) {
|
if ( !ENABLE_NPM_FAILOVER ) {
|
||||||
res._log.cacheHit = '!!!';
|
res._log.cacheHit = '!!!';
|
||||||
return Promise.reject( { status:404, message: {}});
|
return Promise.reject( { status: 404 });
|
||||||
}
|
}
|
||||||
res._log.cacheHit = '---';
|
res._log.cacheHit = '---';
|
||||||
return fetchAndCacheMetadata( packageName, cacheFile );
|
return fetchAndCacheMetadata( packageName, cacheFile );
|
||||||
@@ -68,7 +68,7 @@ app.get( '/:package/-/:tarball', function( req, res, next ){
|
|||||||
if( !isExists ){
|
if( !isExists ){
|
||||||
if ( !ENABLE_NPM_FAILOVER ) {
|
if ( !ENABLE_NPM_FAILOVER ) {
|
||||||
res._log.cacheHit = '!!!';
|
res._log.cacheHit = '!!!';
|
||||||
return Promise.reject( { status: 404, message: {} });
|
return Promise.reject( { status: 404 });
|
||||||
}
|
}
|
||||||
res._log.cacheHit = '---';
|
res._log.cacheHit = '---';
|
||||||
return fetchAndCacheTarball( packageName, version, packagePath );
|
return fetchAndCacheTarball( packageName, version, packagePath );
|
||||||
@@ -84,17 +84,15 @@ app.get( '/:package/-/:tarball', function( req, res, next ){
|
|||||||
|
|
||||||
// catch 404 and forward to error handler
|
// catch 404 and forward to error handler
|
||||||
app.use(function(req, res, next) {
|
app.use(function(req, res, next) {
|
||||||
var err = new Error('Not Found');
|
next({ status: 404 });
|
||||||
err.status = 404;
|
|
||||||
next(err);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
// error handlers
|
// error handlers
|
||||||
|
|
||||||
app.use(function(err, req, res, next) {
|
app.use(function(err, req, res, next) {
|
||||||
|
var message = err.message || err;
|
||||||
err.stack && console.log( err.stack );
|
err.stack && console.log( err.stack );
|
||||||
res.status(err.status || 500);
|
res.status(err.status || 500);
|
||||||
var message = err.message || err;
|
|
||||||
// NPM registry returns empty objects for unknown packages
|
// NPM registry returns empty objects for unknown packages
|
||||||
if( err.status == 404 ){
|
if( err.status == 404 ){
|
||||||
message = {};
|
message = {};
|
||||||
|
|||||||
Reference in New Issue
Block a user