time-convertor

Convert time across timezones
git clone http://git.hanabi.in/repos/time-convertor.git
Log | Files | Refs | README | LICENSE

commit 68c26873173b6e50ee569d415c79f935638e43d6
parent 22fa942f2170ae58acd85b499cadc511949c7991
Author: Agastya Chandrakant <me@hanabi.in>
Date:   Sun, 17 May 2020 22:02:31 +0530

server file commit

Diffstat:
Aserver/.env | 2++
Dserver/index.js | 18------------------
Aserver/server.js | 26++++++++++++++++++++++++++
3 files changed, 28 insertions(+), 18 deletions(-)

diff --git a/server/.env b/server/.env @@ -0,0 +1 @@ +PORT=8090 +\ No newline at end of file diff --git a/server/index.js b/server/index.js @@ -1,18 +0,0 @@ -const express = require('express'); -const server = expres(); -const PORT = process.env.port || 8080; - -server.get('/', function (req, res) { - res.send('Hello from server'); -}); - -server.get('/:from/:to', function (req, res) { - const { from, to } = req.params; - res.send(`From: ${from} To: ${to}`); -}); - -function listen(port) { - console.log(`Server is now running on port ${port}...`); -} - -server.listen(PORT, listening(PORT)); diff --git a/server/server.js b/server/server.js @@ -0,0 +1,26 @@ +const dotenv = require('dotenv'); +const express = require('express'); +const path = require('path'); + +const envPath = path.join(__dirname, '.env'); +dotenv.config({ + path: envPath, +}); + +const server = express(); +const PORT = process.env.PORT || 8080; + +server.get('/', function (req, res) { + res.send('Hello from server'); +}); + +server.get('/:from/:to', function (req, res) { + const { from, to } = req.params; + res.send(`From: ${from} To: ${to}`); +}); + +function listening(port) { + console.log(`Server is now running on port ${port}...`); +} + +server.listen(PORT, listening(PORT));