1
0
Fork 0
mirror of https://github.com/codex-team/codex.docs.git synced 2025-07-24 23:59:46 +02:00

Move testing to 3001 port (#8)

Create separate database for testing
Add runtime configuration file support
This commit is contained in:
George Berezhnoy 2018-10-07 19:15:10 +03:00 committed by GitHub
parent 073772c047
commit 452d0ae816
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
17 changed files with 547 additions and 36 deletions

13
bin/www
View file

@ -6,11 +6,12 @@
const app = require('../src/app');
const debug = require('debug')('codex.editor.docs:server');
const http = require('http');
const config = require('../config');
/**
* Get port from environment and store in Express.
*/
const port = normalizePort(process.env.PORT || '3000');
const port = normalizePort(config.port || '3000');
app.set('port', port);
@ -30,16 +31,16 @@ server.on('listening', onListening);
* Normalize a port into a number, string, or false.
*/
function normalizePort(val) {
const port = parseInt(val, 10);
const value = parseInt(val, 10);
if (isNaN(port)) {
if (isNaN(value)) {
// named pipe
return val;
}
if (port >= 0) {
if (value >= 0) {
// port number
return port;
return value;
}
return false;
@ -62,11 +63,9 @@ function onError(error) {
case 'EACCES':
console.error(bind + ' requires elevated privileges');
process.exit(1);
break;
case 'EADDRINUSE':
console.error(bind + ' is already in use');
process.exit(1);
break;
default:
throw error;
}