refactor: Cleanup (#21)
* refactor(routes): remove unused sitemap route * style(comments): enforce consistent comment style * style(exports): enforce consistent export style * chore: Add jsDoc for contentful service * chore: Add jsDoc for contentful service \n \n closes #23 * refactor(app): move query parameter comment to right position and mention comment route middleware * test(npm): add temporary test script * refactor(middlewares): split up bootstrap middleware - fixes #23759 * refactor(cookies): use constances to give context the maxAge cookie setting * refactor(variables): use more descriptive names for variables * space became spaceId when it was just the id not the full space instance * all (access) token variable name variants became [api-type]Token * all clients are now called deliveryClient or previewClient * cpa and cda only remain when they are used as actual API id * env variables names adjusted * perf(helpers): only run marked when content is not empty * refactor(comments): fix typos * refactor(comments): add hint why error is logged to console in settings * chore: Add comments to routes and services * refactor(requires): order and group requires * fix(settings): add validation for wrong preview token * chore: Add comments to routes * chore: fix typo * chore: console.error -> throw * chore: move cookie name to a constant * chore: Fix app.js comment * typo: removing t * chore: typos * chore: removed unnecessary comment line sign * chore: newline for readabillity * chore: remove dangling `t` * chore: remove `t`, add `l` * chore: typos * Fleshed out title * build(npm): remove unused dependencies * build(npm): upgrade to latest stable contentful sdk * chore: Addressing David feedbak * fix(credentials): update to match the new space * chore: Addressing code review comments * chore: Addressing code review comments * chore: res -> response, req-> request * chore: include exactly what we need * chore: Address JPs comments * chore: Address JPs comments * chore: Address Fredericks comments * chore: Address Fredericks comments * fixup! chore: Address Fredericks comments * fixup! fixup! chore: Address Fredericks comments * fixup! fixup! fixup! chore: Address Fredericks comments * fixup! fixup! fixup! fixup! chore: Address Fredericks comments * fixup! fixup! fixup! fixup! fixup! chore: Address Fredericks comments * fixup! fixup! fixup! fixup! fixup! fixup! chore: Address Fredericks comments
This commit is contained in:
30
bin/www
30
bin/www
@@ -1,46 +1,42 @@
|
||||
#!/usr/bin/env node
|
||||
|
||||
/**
|
||||
* Module dependencies.
|
||||
* Module dependencies
|
||||
*/
|
||||
|
||||
const app = require('../app')
|
||||
const http = require('http')
|
||||
/**
|
||||
* Get port from environment and store in Express.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Get port from environment and store in Express
|
||||
*/
|
||||
const port = normalizePort(process.env.PORT || '3000')
|
||||
app.set('port', port)
|
||||
|
||||
/**
|
||||
* Create HTTP server.
|
||||
* Create HTTP server
|
||||
*/
|
||||
|
||||
const server = http.createServer(app)
|
||||
|
||||
/**
|
||||
* Listen on provided port, on all network interfaces.
|
||||
* Listen on provided port, on all network interfaces
|
||||
*/
|
||||
|
||||
server.listen(port)
|
||||
server.on('error', onError)
|
||||
server.on('listening', onListening)
|
||||
|
||||
/**
|
||||
* Normalize a port into a number, string, or false.
|
||||
* Normalize a port into a number, string, or false
|
||||
*/
|
||||
|
||||
function normalizePort (val) {
|
||||
const port = parseInt(val, 10)
|
||||
|
||||
if (isNaN(port)) {
|
||||
// named pipe
|
||||
// Named pipe
|
||||
return val
|
||||
}
|
||||
|
||||
if (port >= 0) {
|
||||
// port number
|
||||
// Port number
|
||||
return port
|
||||
}
|
||||
|
||||
@@ -48,9 +44,8 @@ function normalizePort (val) {
|
||||
}
|
||||
|
||||
/**
|
||||
* Event listener for HTTP server "error" event.
|
||||
* Event listener for HTTP server "error" event
|
||||
*/
|
||||
|
||||
function onError (error) {
|
||||
if (error.syscall !== 'listen') {
|
||||
throw error
|
||||
@@ -60,7 +55,7 @@ function onError (error) {
|
||||
? 'Pipe ' + port
|
||||
: 'Port ' + port
|
||||
|
||||
// handle specific listen errors with friendly messages
|
||||
// Handle specific listen errors with friendly messages
|
||||
switch (error.code) {
|
||||
case 'EACCES':
|
||||
console.error(bind + ' requires elevated privileges')
|
||||
@@ -76,9 +71,8 @@ function onError (error) {
|
||||
}
|
||||
|
||||
/**
|
||||
* Event listener for HTTP server "listening" event.
|
||||
* Event listener for HTTP server "listening" event
|
||||
*/
|
||||
|
||||
function onListening () {
|
||||
const addr = server.address()
|
||||
const bind = typeof addr === 'string'
|
||||
|
||||
Reference in New Issue
Block a user