From 42a1ad4182541de9bb03b50205e8c3c244aa9b47 Mon Sep 17 00:00:00 2001 From: Pierre HUBERT Date: Sat, 19 Jan 2019 08:24:49 +0100 Subject: [PATCH] Initial commit - Added basic HTTP server --- README.MD | 12 ++++++++++++ config.js | 10 ++++++++++ index.js | 31 +++++++++++++++++++++++++++++++ 3 files changed, 53 insertions(+) create mode 100644 README.MD create mode 100644 config.js create mode 100644 index.js diff --git a/README.MD b/README.MD new file mode 100644 index 0000000..146ed2b --- /dev/null +++ b/README.MD @@ -0,0 +1,12 @@ +# NodeSignalExchanger + +A lightweight node application that allows to exchange signals connection through websockets. + + +## Requirements +```sh +sudo apt install nodejs node-express node-wc +``` + +## Author +Pierre HUBERT 2019 \ No newline at end of file diff --git a/config.js b/config.js new file mode 100644 index 0000000..b5fd87d --- /dev/null +++ b/config.js @@ -0,0 +1,10 @@ +/** + * Project configuration + * + * @author Pierre HUBERT + */ + +/** + * The port into which the server listen + */ +exports.port = 8081; \ No newline at end of file diff --git a/index.js b/index.js new file mode 100644 index 0000000..d0c4467 --- /dev/null +++ b/index.js @@ -0,0 +1,31 @@ +/** + * Project main module + * + * @author Pierre HUBERT + */ + +/** + * Import requirements + */ +const express = require("express"); +const app = express(); +const WebSocket = require("ws"); + +/** + * Import project modules + */ +const config = require("./config"); + +/** + * If user tries to connect to home page, + * show a message to explains him what is the + * purpose of this service + */ +app.get("/", (req, res) => { + res.send("Welcome to NodeSignalExchanger!"); +}); + + +var server = app.listen(config.port, () => { + console.log("Application listening on port " + config.port); +}) \ No newline at end of file