Skip to content

Commit

Permalink
chore(config): Move env.json file
Browse files Browse the repository at this point in the history
  • Loading branch information
Sander Koenders committed Sep 10, 2018
1 parent faf4de1 commit 627b672
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 23 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
.Trash-*
/.idea
/node_modules/
/env.json
config/env.json

/**/*.js
package-lock.json
32 changes: 17 additions & 15 deletions bin/www
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
#!/usr/bin/env node
"use strict";
'use strict';

const debug = require("debug")("express:server");
const http = require("http");
/* tslint:disable:no-console */
/* tslint:disable:no-var-requires */
const debug = require('debug')('express:server');
const http = require('http');

try {
const env = require("../env.json");
const env = require('../env.json');

startServer(env);
} catch (err) {
Expand All @@ -15,20 +17,20 @@ try {
function startServer(env) {
env.port = normalizePort(env.port);

const main = new (require("../src/main"))(env);
const main = new (require('../src/main'))(env);

main.App.set("port", env.port);
main.App.set('port', env.port);

const server = http.createServer(main.App);

server.listen(env.port);

server.on("error", onError);
server.on("listening", main.onListening.bind(main));
server.on('error', onError);
server.on('listening', main.onListening.bind(main));
}

function normalizePort(val) {
var port = parseInt(val, 10);
const port = parseInt(val, 10);

if (isNaN(port)) {
return val;
Expand All @@ -42,20 +44,20 @@ function normalizePort(val) {
}

function onError(error) {
if (error.syscall !== "listen") {
if (error.syscall !== 'listen') {
throw error;
}

var bind = typeof port === "string" ? "Pipe " + port : "Port " + port;
const bind = typeof port === 'string' ? 'Pipe ' + port : 'Port ' + port;

// handle specific listen errors with friendly messages
switch (error.code) {
case "EACCES":
console.error(bind + " requires elevated privileges");
case 'EACCES':
console.error(bind + ' requires elevated privileges');
process.exit(1);
break;
case "EADDRINUSE":
console.error(bind + " is already in use");
case 'EADDRINUSE':
console.error(bind + ' is already in use');
process.exit(1);
break;
default:
Expand Down
7 changes: 0 additions & 7 deletions env.json.example

This file was deleted.

0 comments on commit 627b672

Please sign in to comment.