Style tweaks

This commit is contained in:
MICHAEL JACKSON 2017-11-25 20:28:55 -08:00
parent 847e55cd0b
commit b06de06d89
2 changed files with 23 additions and 21 deletions

View File

@ -1,6 +1,6 @@
const http = require('http') const http = require("http")
const throng = require('throng') const throng = require("throng")
const createServer = require('./server/createServer') const createServer = require("./server/createServer")
const port = parseInt(process.env.PORT, 10) || 5000 const port = parseInt(process.env.PORT, 10) || 5000
@ -10,22 +10,24 @@ function startServer(id) {
// Heroku dynos automatically timeout after 30s. Set our // Heroku dynos automatically timeout after 30s. Set our
// own timeout here to force sockets to close before that. // own timeout here to force sockets to close before that.
// https://devcenter.heroku.com/articles/request-timeout // https://devcenter.heroku.com/articles/request-timeout
server.setTimeout(25000, function (socket) { server.setTimeout(25000, function(socket) {
const message = `Timeout of 25 seconds exceeded` const message = `Timeout of 25 seconds exceeded`
socket.end([ socket.end(
'HTTP/1.1 503 Service Unavailable', [
'Date: ' + (new Date).toGMTString(), "HTTP/1.1 503 Service Unavailable",
'Content-Length: ' + Buffer.byteLength(message), "Date: " + new Date().toGMTString(),
'Content-Type: text/plain', "Content-Length: " + Buffer.byteLength(message),
'Connection: close', "Content-Type: text/plain",
'', "Connection: close",
"",
message message
].join('\r\n')) ].join("\r\n")
)
}) })
server.listen(port, function () { server.listen(port, function() {
console.log('Server #%s listening on port %s, Ctrl+C to stop', id, port) console.log("Server #%s listening on port %s, Ctrl+C to stop", id, port)
}) })
} }

View File

@ -1,9 +1,9 @@
function createPackageURL(packageName, version, filename, search) { function createPackageURL(packageName, version, pathname, search) {
let pathname = `/${packageName}` let url = `/${packageName}`
if (version != null) pathname += `@${version}` if (version != null) url += `@${version}`
if (filename) pathname += filename if (pathname) url += pathname
if (search) pathname += search if (search) url += search
return pathname return url
} }
module.exports = createPackageURL module.exports = createPackageURL