diff options
author | rohan09-raj <rajrohan1914@gmail.com> | 2022-07-28 19:48:13 +0530 |
---|---|---|
committer | rohan09-raj <rajrohan1914@gmail.com> | 2022-07-28 19:48:13 +0530 |
commit | 337b0a2a7d358a597e114197cf5d12e8ed81a19e (patch) | |
tree | 7c8828b974b021a29e25c7a87ebeaffa24b9cf66 /server | |
parent | 404c7b92eaec55845d08b4da6842fdcfdc587df6 (diff) |
folder structure setup and database addition
Diffstat (limited to 'server')
-rw-r--r-- | server/.env | 2 | ||||
-rw-r--r-- | server/controllers/health.js | 5 | ||||
-rw-r--r-- | server/index.js | 4 | ||||
-rw-r--r-- | server/package.json | 2 | ||||
-rw-r--r-- | server/routes/health.js | 8 |
5 files changed, 21 insertions, 0 deletions
diff --git a/server/.env b/server/.env new file mode 100644 index 0000000..02b7c43 --- /dev/null +++ b/server/.env @@ -0,0 +1,2 @@ +CONNECTION_URL = <MONGODB_URI> +PORT = 5000
\ No newline at end of file diff --git a/server/controllers/health.js b/server/controllers/health.js new file mode 100644 index 0000000..8c443bf --- /dev/null +++ b/server/controllers/health.js @@ -0,0 +1,5 @@ +export const healthCheck = async (req, res) => { + return res.json({ + uptime: process.uptime(), + }); +}; diff --git a/server/index.js b/server/index.js index e92752a..11beb07 100644 --- a/server/index.js +++ b/server/index.js @@ -4,6 +4,8 @@ import mongoose from 'mongoose'; import cors from 'cors'; import dotenv from 'dotenv'; +import userRoutes from './routes/health.js'; + const app = Express(); dotenv.config(); @@ -11,6 +13,8 @@ app.use(bodyParser.json({limit: '30mb', extended: true})); app.use(bodyParser.urlencoded({limit: '30mb', extended: true})); app.use(cors()); +app.use('/', userRoutes); + const CONNECTION_URL = process.env.CONNECTION_URL; const PORT = process.env.PORT; diff --git a/server/package.json b/server/package.json index e7e0e2a..d16b054 100644 --- a/server/package.json +++ b/server/package.json @@ -3,7 +3,9 @@ "version": "1.0.0", "description": "", "main": "index.js", + "type": "module", "scripts": { + "start": "nodemon index.js", "test": "echo \"Error: no test specified\" && exit 1" }, "keywords": [], diff --git a/server/routes/health.js b/server/routes/health.js new file mode 100644 index 0000000..2980322 --- /dev/null +++ b/server/routes/health.js @@ -0,0 +1,8 @@ +import Express from 'express'; +import {healthCheck} from '../controllers/health.js'; + +const router = Express.Router(); + +router.get('/health', healthCheck); + +export default router; |