0
Fork 0
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:
Ashish Surana 2018-10-11 21:47:02 +05:30 committed by Juan Picado @jotadeveloper
parent b19df01b49
commit 3588df5efd
2 changed files with 5 additions and 3 deletions

View file

@ -7,7 +7,7 @@ import _ from 'lodash';
import Path from 'path'; import Path from 'path';
import mime from 'mime'; 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 { validateMetadata, isObject, ErrorCode } from '../../../lib/utils';
import { media, expectJson, allow } from '../../middleware'; import { media, expectJson, allow } from '../../middleware';
import { notify } from '../../../lib/notify'; import { notify } from '../../../lib/notify';
@ -121,7 +121,7 @@ export default function(router: Router, auth: IAuth, storage: IStorageHandler, c
try { try {
metadata = validateMetadata(req.body, name); metadata = validateMetadata(req.body, name);
} catch (err) { } catch (err) {
return next(ErrorCode.getBadData('bad incoming package data')); return next(ErrorCode.getBadData(API_ERROR.BAD_PACKAGE_DATA));
} }
if (req.params._rev) { if (req.params._rev) {
@ -187,7 +187,7 @@ export default function(router: Router, auth: IAuth, storage: IStorageHandler, c
stream.on('success', function() { stream.on('success', function() {
res.status(201); res.status(201);
return next({ return next({
ok: 'tarball uploaded successfully', ok: API_MESSAGE.TARBALL_UPLOADED,
}); });
}); });
}); });

View file

@ -79,6 +79,7 @@ export const API_MESSAGE = {
PKG_CHANGED: 'package changed', PKG_CHANGED: 'package changed',
PKG_REMOVED: 'package removed', PKG_REMOVED: 'package removed',
PKG_PUBLISHED: 'package published', PKG_PUBLISHED: 'package published',
TARBALL_UPLOADED: 'tarball uploaded successfully',
TARBALL_REMOVED: 'tarball removed', TARBALL_REMOVED: 'tarball removed',
TAG_UPDATED: 'tags updated', TAG_UPDATED: 'tags updated',
TAG_REMOVED: 'tag removed', TAG_REMOVED: 'tag removed',
@ -110,6 +111,7 @@ export const API_ERROR = {
DEPRECATED_BASIC_HEADER: 'basic authentication is deprecated, please use JWT instead', DEPRECATED_BASIC_HEADER: 'basic authentication is deprecated, please use JWT instead',
BAD_FORMAT_USER_GROUP: 'user groups is different than an array', BAD_FORMAT_USER_GROUP: 'user groups is different than an array',
RESOURCE_UNAVAILABLE: 'resource unavailable', RESOURCE_UNAVAILABLE: 'resource unavailable',
BAD_PACKAGE_DATA: 'bad incoming package data',
}; };
export const APP_ERROR = { export const APP_ERROR = {