mirror of
https://github.com/verdaccio/verdaccio.git
synced 2025-04-01 02:42:23 -05:00
refactor: replace all 404 with NOT_FOUND constant (#1050)
Resolve one eslint warning
This commit is contained in:
parent
94c20b44f5
commit
d41a990e97
7 changed files with 12 additions and 10 deletions
|
@ -6,7 +6,7 @@
|
|||
import _ from 'lodash';
|
||||
import { addScope, addGravatarSupport, deleteProperties, sortByName, parseReadme } from '../../../lib/utils';
|
||||
import { allow } from '../../middleware';
|
||||
import { DIST_TAGS } from '../../../lib/constants';
|
||||
import { DIST_TAGS, HTTP_STATUS } from '../../../lib/constants';
|
||||
import type { Router } from 'express';
|
||||
import type { IAuth, $ResponseExtend, $RequestExtend, $NextFunctionVer, IStorageHandler, $SidebarPackage } from '../../../../types';
|
||||
|
||||
|
@ -87,7 +87,7 @@ function addPackageWebApi(route: Router, storage: IStorageHandler, auth: IAuth)
|
|||
sideBarInfo = addGravatarSupport(sideBarInfo);
|
||||
next(sideBarInfo);
|
||||
} else {
|
||||
res.status(404);
|
||||
res.status(HTTP_STATUS.NOT_FOUND);
|
||||
res.end();
|
||||
}
|
||||
},
|
||||
|
|
|
@ -396,11 +396,12 @@ class LocalStorage implements IStorage {
|
|||
(uploadStream: any).abort = function() {};
|
||||
(uploadStream: any).done = function() {};
|
||||
|
||||
uploadStream._transform = function(data) {
|
||||
uploadStream._transform = function(data, ...args) {
|
||||
shaOneHash.update(data);
|
||||
// measure the length for validation reasons
|
||||
length += data.length;
|
||||
_transform.apply(uploadStream, arguments);
|
||||
const appliedData = [data, ...args];
|
||||
_transform.apply(uploadStream, appliedData);
|
||||
};
|
||||
|
||||
if (name === STORAGE.PACKAGE_FILE_NAME || name === '__proto__') {
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
|
||||
import _ from 'lodash';
|
||||
import {readFile} from '../lib/test.utils';
|
||||
import { HTTP_STATUS } from '../../../src/lib/constants';
|
||||
|
||||
const readTags = () => readFile('../fixtures/tags.json');
|
||||
|
||||
|
@ -9,7 +10,7 @@ export default function(server, express) {
|
|||
test('tags - testing for 404', () => {
|
||||
return server.getPackage('testexp_tags')
|
||||
// shouldn't exist yet
|
||||
.status(404)
|
||||
.status(HTTP_STATUS.NOT_FOUND)
|
||||
.body_error(/no such package/);
|
||||
});
|
||||
|
||||
|
|
|
@ -3,7 +3,7 @@ import _ from 'lodash';
|
|||
import path from 'path';
|
||||
import rimraf from 'rimraf';
|
||||
|
||||
import {HEADERS} from '../../../src/lib/constants';
|
||||
import { HEADERS, HTTP_STATUS } from '../../../src/lib/constants';
|
||||
import configDefault from '../partials/config/config_access';
|
||||
import Config from '../../../src/lib/config';
|
||||
import endPointAPI from '../../../src/api/index';
|
||||
|
@ -60,7 +60,7 @@ describe('api with no limited access configuration', () => {
|
|||
.get('/jquery')
|
||||
.set('content-type', HEADERS.JSON_CHARSET)
|
||||
.expect('Content-Type', /json/)
|
||||
.expect(404)
|
||||
.expect(HTTP_STATUS.NOT_FOUND)
|
||||
.end(function(err, res) {
|
||||
if (err) {
|
||||
return done(err);
|
||||
|
|
|
@ -358,7 +358,7 @@ describe('LocalStorage', () => {
|
|||
const stream = storage.addTarball('unexsiting-package', tarballName);
|
||||
stream.on('error', (err) => {
|
||||
expect(err).not.toBeNull();
|
||||
expect(err.statusCode).toEqual(404);
|
||||
expect(err.statusCode).toEqual(HTTP_STATUS.NOT_FOUND);
|
||||
expect(err.message).toMatch(/no such package available/);
|
||||
done();
|
||||
});
|
||||
|
|
|
@ -69,7 +69,7 @@ describe('UpStorge', () => {
|
|||
|
||||
proxy.getRemoteMetadata('@verdaccio/fake-package', {etag: '123456'}, (err) => {
|
||||
expect(err).not.toBeNull();
|
||||
expect(err.statusCode).toBe(404);
|
||||
expect(err.statusCode).toBe(HTTP_STATUS.NOT_FOUND);
|
||||
expect(err.message).toMatch(API_ERROR.NOT_PACKAGE_UPLINK);
|
||||
done();
|
||||
});
|
||||
|
|
|
@ -70,7 +70,7 @@ describe('Request Functional', () => {
|
|||
method: 'GET'
|
||||
};
|
||||
// $FlowFixMe
|
||||
smartRequest(options).status(404).then((result)=> {
|
||||
smartRequest(options).status(HTTP_STATUS.NOT_FOUND).then((result)=> {
|
||||
// this never is resolved
|
||||
}, function(error) {
|
||||
expect(error.code).toBe('ENOTFOUND');
|
||||
|
|
Loading…
Add table
Reference in a new issue