From 38bf0fe54100e794d50160d6c6ae83cc47b8290e Mon Sep 17 00:00:00 2001 From: Luke Date: Tue, 15 Sep 2015 14:01:51 +0100 Subject: [PATCH] added config setup --- .gitignore | 3 +++ chat.js | 11 ++++++----- config.example.js | 6 ++++++ 3 files changed, 15 insertions(+), 5 deletions(-) create mode 100644 config.example.js diff --git a/.gitignore b/.gitignore index 123ae94..8e1a7ba 100644 --- a/.gitignore +++ b/.gitignore @@ -25,3 +25,6 @@ build/Release # Dependency directory # https://www.npmjs.org/doc/misc/npm-faq.html#should-i-check-my-node_modules-folder-into-git node_modules + +# config file +config.js \ No newline at end of file diff --git a/chat.js b/chat.js index 5e29760..1d69e46 100644 --- a/chat.js +++ b/chat.js @@ -1,7 +1,8 @@ // Load the TCP Library -net = require('net'); -clc = require('cli-color'); -moment = require('moment'); +var net = require('net'), + clc = require('cli-color'), + moment = require('moment'), + config = require('./config'); // Keep track of the chat clients var clients = []; @@ -106,7 +107,7 @@ net.createServer(function (socket) { socket.on('end', function () { clientService.removeUser(socket); }); -}).listen(5000); +}).listen(config.server.port); // Put a friendly message on the terminal of the server. -console.log("Chat server running at port 5000"); +console.log("Chat server running at port " + config.server.port); diff --git a/config.example.js b/config.example.js new file mode 100644 index 0000000..ee452e9 --- /dev/null +++ b/config.example.js @@ -0,0 +1,6 @@ +var config = {}; + +config.server = {}; +config.server.port ='5000'; + +module.exports = config; \ No newline at end of file