mirror of
https://github.com/verdaccio/verdaccio.git
synced 2024-12-16 21:56:25 -05:00
refactor: moving API response to constants (#1069)
- creates TARBALL_UPLOADED & BAD_PACKAGE_DATA constant
This commit is contained in:
parent
b19df01b49
commit
3588df5efd
2 changed files with 5 additions and 3 deletions
|
@ -7,7 +7,7 @@ import _ from 'lodash';
|
|||
import Path from 'path';
|
||||
import mime from 'mime';
|
||||
|
||||
import { API_MESSAGE, HEADERS, DIST_TAGS } from '../../../lib/constants';
|
||||
import { API_MESSAGE, HEADERS, DIST_TAGS, API_ERROR } from '../../../lib/constants';
|
||||
import { validateMetadata, isObject, ErrorCode } from '../../../lib/utils';
|
||||
import { media, expectJson, allow } from '../../middleware';
|
||||
import { notify } from '../../../lib/notify';
|
||||
|
@ -121,7 +121,7 @@ export default function(router: Router, auth: IAuth, storage: IStorageHandler, c
|
|||
try {
|
||||
metadata = validateMetadata(req.body, name);
|
||||
} catch (err) {
|
||||
return next(ErrorCode.getBadData('bad incoming package data'));
|
||||
return next(ErrorCode.getBadData(API_ERROR.BAD_PACKAGE_DATA));
|
||||
}
|
||||
|
||||
if (req.params._rev) {
|
||||
|
@ -187,7 +187,7 @@ export default function(router: Router, auth: IAuth, storage: IStorageHandler, c
|
|||
stream.on('success', function() {
|
||||
res.status(201);
|
||||
return next({
|
||||
ok: 'tarball uploaded successfully',
|
||||
ok: API_MESSAGE.TARBALL_UPLOADED,
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
|
@ -79,6 +79,7 @@ export const API_MESSAGE = {
|
|||
PKG_CHANGED: 'package changed',
|
||||
PKG_REMOVED: 'package removed',
|
||||
PKG_PUBLISHED: 'package published',
|
||||
TARBALL_UPLOADED: 'tarball uploaded successfully',
|
||||
TARBALL_REMOVED: 'tarball removed',
|
||||
TAG_UPDATED: 'tags updated',
|
||||
TAG_REMOVED: 'tag removed',
|
||||
|
@ -110,6 +111,7 @@ export const API_ERROR = {
|
|||
DEPRECATED_BASIC_HEADER: 'basic authentication is deprecated, please use JWT instead',
|
||||
BAD_FORMAT_USER_GROUP: 'user groups is different than an array',
|
||||
RESOURCE_UNAVAILABLE: 'resource unavailable',
|
||||
BAD_PACKAGE_DATA: 'bad incoming package data',
|
||||
};
|
||||
|
||||
export const APP_ERROR = {
|
||||
|
|
Loading…
Reference in a new issue