0
Fork 0
mirror of https://github.com/verdaccio/verdaccio.git synced 2024-12-16 21:56:25 -05:00

chore: rename method to camelCase

This commit is contained in:
Juan Picado @jotadeveloper 2018-03-22 18:31:26 +01:00
parent 4f395500b6
commit 9c39cf0c1e
No known key found for this signature in database
GPG key ID: 18AC54485952D158
4 changed files with 20 additions and 18 deletions

View file

@ -5,7 +5,7 @@ import Path from 'path';
import mime from 'mime';
import {DIST_TAGS, validate_metadata, isObject, ErrorCode} from '../../../lib/utils';
import {media, expect_json, allow} from '../../middleware';
import {media, expectJson, allow} from '../../middleware';
import {notify} from '../../../lib/notify';
import type {Router} from 'express';
@ -17,7 +17,7 @@ export default function(router: Router, auth: IAuth, storage: IStorageHandler, c
// publishing a package
router.put('/:package/:_rev?/:revision?', can('publish'),
media(mime.getType('json')), expect_json, function(req: $RequestExtend, res: $ResponseExtend, next: $NextFunctionVer) {
media(mime.getType('json')), expectJson, function(req: $RequestExtend, res: $ResponseExtend, next: $NextFunctionVer) {
const name = req.params.package;
let metadata;
const create_tarball = function(filename: string, data, cb: Callback) {
@ -110,7 +110,7 @@ export default function(router: Router, auth: IAuth, storage: IStorageHandler, c
}
if (req.params._rev) {
storage.change_package(name, metadata, req.params.revision, function(err) {
storage.changePackage(name, metadata, req.params.revision, function(err) {
after_change(err, 'package changed');
});
} else {
@ -122,7 +122,7 @@ export default function(router: Router, auth: IAuth, storage: IStorageHandler, c
// unpublishing an entire package
router.delete('/:package/-rev/*', can('publish'), function(req: $RequestExtend, res: $ResponseExtend, next: $NextFunctionVer) {
storage.remove_package(req.params.package, function(err) {
storage.removePackage(req.params.package, function(err) {
if (err) {
return next(err);
}
@ -134,7 +134,7 @@ export default function(router: Router, auth: IAuth, storage: IStorageHandler, c
// removing a tarball
router.delete('/:package/-/:filename/-rev/:revision', can('publish'),
function(req: $RequestExtend, res: $ResponseExtend, next: $NextFunctionVer) {
storage.remove_tarball(req.params.package, req.params.filename, req.params.revision, function(err) {
storage.removeTarball(req.params.package, req.params.filename, req.params.revision, function(err) {
if (err) {
return next(err);
}
@ -156,6 +156,7 @@ export default function(router: Router, auth: IAuth, storage: IStorageHandler, c
complete = true;
stream.done();
});
req.on('close', function() {
if (!complete) {
stream.abort();
@ -165,6 +166,7 @@ export default function(router: Router, auth: IAuth, storage: IStorageHandler, c
stream.on('error', function(err) {
return res.report_error(err);
});
stream.on('success', function() {
res.status(201);
return next({
@ -175,15 +177,15 @@ export default function(router: Router, auth: IAuth, storage: IStorageHandler, c
// adding a version
router.put('/:package/:version/-tag/:tag', can('publish'),
media(mime.getType('json')), expect_json, function(req: $RequestExtend, res: $ResponseExtend, next: $NextFunctionVer) {
let name = req.params.package;
let version = req.params.version;
let tag = req.params.tag;
media(mime.getType('json')), expectJson, function(req: $RequestExtend, res: $ResponseExtend, next: $NextFunctionVer) {
const {version, tag} = req.params;
const name = req.params.package;
storage.addVersion(name, version, req.body, tag, function(err) {
if (err) {
return next(err);
}
res.status(201);
return next({
ok: 'package published',

View file

@ -73,7 +73,7 @@ export function encodeScopePackage(req: $RequestExtend, res: $ResponseExtend, ne
next();
}
export function expect_json(req: $RequestExtend, res: $ResponseExtend, next: $NextFunctionVer) {
export function expectJson(req: $RequestExtend, res: $ResponseExtend, next: $NextFunctionVer) {
if (!isObject(req.body)) {
return next( ErrorCode.get400('can\'t parse incoming json') );
}

View file

@ -190,7 +190,7 @@ class Storage implements IStorageHandler {
* @param {*} tag_hash
* @param {*} callback
*/
replace_tags(name: string, tagHash: MergeTags, callback: Callback) {
replaceTags(name: string, tagHash: MergeTags, callback: Callback) {
this.logger.warn('method deprecated');
this.localStorage.mergeTags(name, tagHash, callback);
}
@ -204,7 +204,7 @@ class Storage implements IStorageHandler {
* @param {*} revision
* @param {*} callback
*/
change_package(name: string, metadata: Package, revision: string, callback: Callback) {
changePackage(name: string, metadata: Package, revision: string, callback: Callback) {
this.localStorage.changePackage(name, metadata, revision, callback);
}
@ -215,7 +215,7 @@ class Storage implements IStorageHandler {
* @param {*} name
* @param {*} callback
*/
remove_package(name: string, callback: Callback) {
removePackage(name: string, callback: Callback) {
this.localStorage.removePackage(name, callback);
// update the indexer
Search.remove(name);
@ -232,7 +232,7 @@ class Storage implements IStorageHandler {
* @param {*} revision
* @param {*} callback
*/
remove_tarball(name: string, filename: string, revision: string, callback: Callback) {
removeTarball(name: string, filename: string, revision: string, callback: Callback) {
this.localStorage.removeTarball(name, filename, revision, callback);
}

View file

@ -81,10 +81,10 @@ export interface IStorageHandler {
addPackage(name: string, metadata: any, callback: Function): void;
addVersion(name: string, version: string, metadata: Version, tag: StringValue, callback: Callback): void;
mergeTags(name: string, tagHash: MergeTags, callback: Callback): void;
replace_tags(name: string, tagHash: MergeTags, callback: Callback): void;
change_package(name: string, metadata: Package, revision: string, callback: Callback): void;
remove_package(name: string, callback: Callback): void;
remove_tarball(name: string, filename: string, revision: string, callback: Callback): void;
replaceTags(name: string, tagHash: MergeTags, callback: Callback): void;
changePackage(name: string, metadata: Package, revision: string, callback: Callback): void;
removePackage(name: string, callback: Callback): void;
removeTarball(name: string, filename: string, revision: string, callback: Callback): void;
addTarball(name: string, filename: string): IUploadTarball;
getTarball(name: string, filename: string): IReadTarball;
getPackage(options: any): void;