Small tweaks + whitespace
This commit is contained in:
parent
a8471ed950
commit
c0e0f899d2
|
@ -4,10 +4,11 @@ const validateNpmPackageName = require("validate-npm-package-name");
|
|||
* Reject requests for invalid npm package names.
|
||||
*/
|
||||
function validatePackageName(req, res, next) {
|
||||
const nameErrors = validateNpmPackageName(req.packageName).errors;
|
||||
const errors = validateNpmPackageName(req.packageName).errors;
|
||||
|
||||
if (errors) {
|
||||
const reason = errors.join(", ");
|
||||
|
||||
if (nameErrors) {
|
||||
const reason = nameErrors.join(", ");
|
||||
return res
|
||||
.status(403)
|
||||
.type("text")
|
||||
|
|
|
@ -1,8 +1,10 @@
|
|||
function createPackageURL(packageName, version, pathname, search) {
|
||||
let url = `/${packageName}`;
|
||||
|
||||
if (version != null) url += `@${version}`;
|
||||
if (pathname) url += pathname;
|
||||
if (search) url += search;
|
||||
|
||||
return url;
|
||||
}
|
||||
|
||||
|
|
|
@ -32,15 +32,15 @@ const fetchMutex = createMutex((packageConfig, callback) => {
|
|||
callback(error);
|
||||
}
|
||||
} else {
|
||||
lockfile.check(outputDir).then(isLocked => {
|
||||
if (isLocked) {
|
||||
lockfile.check(outputDir).then(locked => {
|
||||
if (locked) {
|
||||
// Another process on this same machine has locked the
|
||||
// directory. We need to wait for it to be unlocked
|
||||
// before we callback.
|
||||
const timer = setInterval(() => {
|
||||
lockfile.check(outputDir).then(
|
||||
isLocked => {
|
||||
if (!isLocked) {
|
||||
locked => {
|
||||
if (!locked) {
|
||||
clearInterval(timer);
|
||||
callback(null, outputDir);
|
||||
}
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
const db = require("./redis");
|
||||
|
||||
function incrementCounter(counter, key, by) {
|
||||
function incrementCounter(counter, key, by = 1) {
|
||||
return new Promise((resolve, reject) => {
|
||||
db.hincrby(counter, key, by, (error, value) => {
|
||||
if (error) {
|
||||
|
|
|
@ -7,6 +7,7 @@ function renderPage(page, props) {
|
|||
const html = ReactDOMServer.renderToStaticMarkup(
|
||||
React.createElement(page, props)
|
||||
);
|
||||
|
||||
return doctype + html;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue