@verdaccio/commons-api
Advanced tools
Comparing version 0.0.1 to 0.1.0
@@ -1,2 +0,2 @@ | ||
import createError from 'http-errors'; | ||
import { HttpError } from 'http-errors'; | ||
export declare const DEFAULT_MIN_LIMIT_PASSWORD = 3; | ||
@@ -85,10 +85,13 @@ export declare const HTTP_STATUS: { | ||
}; | ||
export declare function getConflict(message?: string): createError.HttpError; | ||
export declare function getBadData(customMessage?: string): createError.HttpError; | ||
export declare function getBadRequest(customMessage: string): createError.HttpError; | ||
export declare function getInternalError(customMessage?: string): createError.HttpError; | ||
export declare function getUnauthorized(message?: string): createError.HttpError; | ||
export declare function getForbidden(message?: string): createError.HttpError; | ||
export declare function getServiceUnavailable(message?: string): createError.HttpError; | ||
export declare function getNotFound(customMessage?: string): createError.HttpError; | ||
export declare function getCode(statusCode: number, customMessage: string): createError.HttpError; | ||
export declare type VerdaccioError = HttpError & { | ||
code: number; | ||
}; | ||
export declare function getConflict(message?: string): VerdaccioError; | ||
export declare function getBadData(customMessage?: string): VerdaccioError; | ||
export declare function getBadRequest(customMessage: string): VerdaccioError; | ||
export declare function getInternalError(customMessage?: string): VerdaccioError; | ||
export declare function getUnauthorized(message?: string): VerdaccioError; | ||
export declare function getForbidden(message?: string): VerdaccioError; | ||
export declare function getServiceUnavailable(message?: string): VerdaccioError; | ||
export declare function getNotFound(customMessage?: string): VerdaccioError; | ||
export declare function getCode(statusCode: number, customMessage: string): VerdaccioError; |
@@ -110,36 +110,43 @@ "use strict"; | ||
function getError(code, message) { | ||
const err = Object.assign({}, (0, _httpErrors.default)(code, message), { | ||
code | ||
}); | ||
return err; | ||
} | ||
function getConflict(message = API_ERROR.PACKAGE_EXIST) { | ||
return (0, _httpErrors.default)(HTTP_STATUS.CONFLICT, message); | ||
return getError(HTTP_STATUS.CONFLICT, message); | ||
} | ||
function getBadData(customMessage) { | ||
return (0, _httpErrors.default)(HTTP_STATUS.BAD_DATA, customMessage || API_ERROR.BAD_DATA); | ||
return getError(HTTP_STATUS.BAD_DATA, customMessage || API_ERROR.BAD_DATA); | ||
} | ||
function getBadRequest(customMessage) { | ||
return (0, _httpErrors.default)(HTTP_STATUS.BAD_REQUEST, customMessage); | ||
return getError(HTTP_STATUS.BAD_REQUEST, customMessage); | ||
} | ||
function getInternalError(customMessage) { | ||
return customMessage ? (0, _httpErrors.default)(HTTP_STATUS.INTERNAL_ERROR, customMessage) : (0, _httpErrors.default)(HTTP_STATUS.INTERNAL_ERROR); | ||
return customMessage ? getError(HTTP_STATUS.INTERNAL_ERROR, customMessage) : getError(HTTP_STATUS.INTERNAL_ERROR, API_ERROR.UNKNOWN_ERROR); | ||
} | ||
function getUnauthorized(message = 'no credentials provided') { | ||
return (0, _httpErrors.default)(HTTP_STATUS.UNAUTHORIZED, message); | ||
return getError(HTTP_STATUS.UNAUTHORIZED, message); | ||
} | ||
function getForbidden(message = "can't use this filename") { | ||
return (0, _httpErrors.default)(HTTP_STATUS.FORBIDDEN, message); | ||
return getError(HTTP_STATUS.FORBIDDEN, message); | ||
} | ||
function getServiceUnavailable(message = API_ERROR.RESOURCE_UNAVAILABLE) { | ||
return (0, _httpErrors.default)(HTTP_STATUS.SERVICE_UNAVAILABLE, message); | ||
return getError(HTTP_STATUS.SERVICE_UNAVAILABLE, message); | ||
} | ||
function getNotFound(customMessage) { | ||
return (0, _httpErrors.default)(HTTP_STATUS.NOT_FOUND, customMessage || API_ERROR.NO_PACKAGE); | ||
return getError(HTTP_STATUS.NOT_FOUND, customMessage || API_ERROR.NO_PACKAGE); | ||
} | ||
function getCode(statusCode, customMessage) { | ||
return (0, _httpErrors.default)(statusCode, customMessage); | ||
return getError(statusCode, customMessage); | ||
} |
{ | ||
"name": "@verdaccio/commons-api", | ||
"version": "0.0.1", | ||
"version": "0.1.0", | ||
"description": "commons api utilities for verdaccio", | ||
@@ -21,3 +21,3 @@ "main": "lib/index.js", | ||
"eslint": "5.16.0", | ||
"husky": "2.4.1", | ||
"husky": "2.5.0", | ||
"in-publish": "2.0.0", | ||
@@ -33,3 +33,3 @@ "jest": "24.8.0", | ||
"dependencies": { | ||
"http-errors": "^1.7.2" | ||
"http-errors": "1.7.3" | ||
}, | ||
@@ -53,3 +53,3 @@ "lint-staged": { | ||
"build:types": "tsc --emitDeclarationOnly", | ||
"build:js": "babel src/ --out-dir lib --extensions \".ts,.tsx\" --ignore __tests__", | ||
"build:js": "babel src/ --out-dir lib --extensions \".ts,.tsx\"", | ||
"precommit": "lint-staged", | ||
@@ -56,0 +56,0 @@ "prepublish": "in-publish && npm run lint && npm run build || not-in-publish" |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
12764
6
232
2
+ Addedhttp-errors@1.7.3(transitive)
+ Addedsetprototypeof@1.1.1(transitive)
+ Addedtoidentifier@1.0.0(transitive)
- Removedhttp-errors@1.8.1(transitive)
- Removedsetprototypeof@1.2.0(transitive)
- Removedtoidentifier@1.0.1(transitive)
Updatedhttp-errors@1.7.3