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:
parent
4f395500b6
commit
9c39cf0c1e
4 changed files with 20 additions and 18 deletions
|
@ -5,7 +5,7 @@ import Path from 'path';
|
||||||
import mime from 'mime';
|
import mime from 'mime';
|
||||||
|
|
||||||
import {DIST_TAGS, validate_metadata, isObject, ErrorCode} from '../../../lib/utils';
|
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 {notify} from '../../../lib/notify';
|
||||||
|
|
||||||
import type {Router} from 'express';
|
import type {Router} from 'express';
|
||||||
|
@ -17,7 +17,7 @@ export default function(router: Router, auth: IAuth, storage: IStorageHandler, c
|
||||||
|
|
||||||
// publishing a package
|
// publishing a package
|
||||||
router.put('/:package/:_rev?/:revision?', can('publish'),
|
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;
|
const name = req.params.package;
|
||||||
let metadata;
|
let metadata;
|
||||||
const create_tarball = function(filename: string, data, cb: Callback) {
|
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) {
|
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');
|
after_change(err, 'package changed');
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
|
@ -122,7 +122,7 @@ export default function(router: Router, auth: IAuth, storage: IStorageHandler, c
|
||||||
|
|
||||||
// unpublishing an entire package
|
// unpublishing an entire package
|
||||||
router.delete('/:package/-rev/*', can('publish'), function(req: $RequestExtend, res: $ResponseExtend, next: $NextFunctionVer) {
|
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) {
|
if (err) {
|
||||||
return next(err);
|
return next(err);
|
||||||
}
|
}
|
||||||
|
@ -134,7 +134,7 @@ export default function(router: Router, auth: IAuth, storage: IStorageHandler, c
|
||||||
// removing a tarball
|
// removing a tarball
|
||||||
router.delete('/:package/-/:filename/-rev/:revision', can('publish'),
|
router.delete('/:package/-/:filename/-rev/:revision', can('publish'),
|
||||||
function(req: $RequestExtend, res: $ResponseExtend, next: $NextFunctionVer) {
|
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) {
|
if (err) {
|
||||||
return next(err);
|
return next(err);
|
||||||
}
|
}
|
||||||
|
@ -156,6 +156,7 @@ export default function(router: Router, auth: IAuth, storage: IStorageHandler, c
|
||||||
complete = true;
|
complete = true;
|
||||||
stream.done();
|
stream.done();
|
||||||
});
|
});
|
||||||
|
|
||||||
req.on('close', function() {
|
req.on('close', function() {
|
||||||
if (!complete) {
|
if (!complete) {
|
||||||
stream.abort();
|
stream.abort();
|
||||||
|
@ -165,6 +166,7 @@ export default function(router: Router, auth: IAuth, storage: IStorageHandler, c
|
||||||
stream.on('error', function(err) {
|
stream.on('error', function(err) {
|
||||||
return res.report_error(err);
|
return res.report_error(err);
|
||||||
});
|
});
|
||||||
|
|
||||||
stream.on('success', function() {
|
stream.on('success', function() {
|
||||||
res.status(201);
|
res.status(201);
|
||||||
return next({
|
return next({
|
||||||
|
@ -175,15 +177,15 @@ export default function(router: Router, auth: IAuth, storage: IStorageHandler, c
|
||||||
|
|
||||||
// adding a version
|
// adding a version
|
||||||
router.put('/:package/:version/-tag/:tag', can('publish'),
|
router.put('/:package/:version/-tag/:tag', 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) {
|
||||||
let name = req.params.package;
|
const {version, tag} = req.params;
|
||||||
let version = req.params.version;
|
const name = req.params.package;
|
||||||
let tag = req.params.tag;
|
|
||||||
|
|
||||||
storage.addVersion(name, version, req.body, tag, function(err) {
|
storage.addVersion(name, version, req.body, tag, function(err) {
|
||||||
if (err) {
|
if (err) {
|
||||||
return next(err);
|
return next(err);
|
||||||
}
|
}
|
||||||
|
|
||||||
res.status(201);
|
res.status(201);
|
||||||
return next({
|
return next({
|
||||||
ok: 'package published',
|
ok: 'package published',
|
||||||
|
|
|
@ -73,7 +73,7 @@ export function encodeScopePackage(req: $RequestExtend, res: $ResponseExtend, ne
|
||||||
next();
|
next();
|
||||||
}
|
}
|
||||||
|
|
||||||
export function expect_json(req: $RequestExtend, res: $ResponseExtend, next: $NextFunctionVer) {
|
export function expectJson(req: $RequestExtend, res: $ResponseExtend, next: $NextFunctionVer) {
|
||||||
if (!isObject(req.body)) {
|
if (!isObject(req.body)) {
|
||||||
return next( ErrorCode.get400('can\'t parse incoming json') );
|
return next( ErrorCode.get400('can\'t parse incoming json') );
|
||||||
}
|
}
|
||||||
|
|
|
@ -190,7 +190,7 @@ class Storage implements IStorageHandler {
|
||||||
* @param {*} tag_hash
|
* @param {*} tag_hash
|
||||||
* @param {*} callback
|
* @param {*} callback
|
||||||
*/
|
*/
|
||||||
replace_tags(name: string, tagHash: MergeTags, callback: Callback) {
|
replaceTags(name: string, tagHash: MergeTags, callback: Callback) {
|
||||||
this.logger.warn('method deprecated');
|
this.logger.warn('method deprecated');
|
||||||
this.localStorage.mergeTags(name, tagHash, callback);
|
this.localStorage.mergeTags(name, tagHash, callback);
|
||||||
}
|
}
|
||||||
|
@ -204,7 +204,7 @@ class Storage implements IStorageHandler {
|
||||||
* @param {*} revision
|
* @param {*} revision
|
||||||
* @param {*} callback
|
* @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);
|
this.localStorage.changePackage(name, metadata, revision, callback);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -215,7 +215,7 @@ class Storage implements IStorageHandler {
|
||||||
* @param {*} name
|
* @param {*} name
|
||||||
* @param {*} callback
|
* @param {*} callback
|
||||||
*/
|
*/
|
||||||
remove_package(name: string, callback: Callback) {
|
removePackage(name: string, callback: Callback) {
|
||||||
this.localStorage.removePackage(name, callback);
|
this.localStorage.removePackage(name, callback);
|
||||||
// update the indexer
|
// update the indexer
|
||||||
Search.remove(name);
|
Search.remove(name);
|
||||||
|
@ -232,7 +232,7 @@ class Storage implements IStorageHandler {
|
||||||
* @param {*} revision
|
* @param {*} revision
|
||||||
* @param {*} callback
|
* @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);
|
this.localStorage.removeTarball(name, filename, revision, callback);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -81,10 +81,10 @@ export interface IStorageHandler {
|
||||||
addPackage(name: string, metadata: any, callback: Function): void;
|
addPackage(name: string, metadata: any, callback: Function): void;
|
||||||
addVersion(name: string, version: string, metadata: Version, tag: StringValue, callback: Callback): void;
|
addVersion(name: string, version: string, metadata: Version, tag: StringValue, callback: Callback): void;
|
||||||
mergeTags(name: string, tagHash: MergeTags, callback: Callback): void;
|
mergeTags(name: string, tagHash: MergeTags, callback: Callback): void;
|
||||||
replace_tags(name: string, tagHash: MergeTags, callback: Callback): void;
|
replaceTags(name: string, tagHash: MergeTags, callback: Callback): void;
|
||||||
change_package(name: string, metadata: Package, revision: string, callback: Callback): void;
|
changePackage(name: string, metadata: Package, revision: string, callback: Callback): void;
|
||||||
remove_package(name: string, callback: Callback): void;
|
removePackage(name: string, callback: Callback): void;
|
||||||
remove_tarball(name: string, filename: string, revision: string, callback: Callback): void;
|
removeTarball(name: string, filename: string, revision: string, callback: Callback): void;
|
||||||
addTarball(name: string, filename: string): IUploadTarball;
|
addTarball(name: string, filename: string): IUploadTarball;
|
||||||
getTarball(name: string, filename: string): IReadTarball;
|
getTarball(name: string, filename: string): IReadTarball;
|
||||||
getPackage(options: any): void;
|
getPackage(options: any): void;
|
||||||
|
|
Loading…
Reference in a new issue