-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
39 lines (30 loc) · 1.19 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
import cors from "cors";
import * as dotenv from "dotenv";
import express from "express";
import { MongoClient } from "mongodb";
import usersRouter from './routes/users.router.js';
import profileRouter from './routes/dashboard.profile.router.js'
import allocationRouter from './routes/dashboard.allocation.router.js'
import employeeRouter from './routes/dashboard.employees.router.js'
const app = express();
app.use(cors());
app.use(express.json());
dotenv.config();
app.get("/", function (request, response) {
response.send("🙋♂️, 🌏 🎊✨🤩");
});
// const MONGO_URL = 'mongodb://127.0.0.1';
const MONGO_URL = process.env.MONGO_URL;
const PORT = process.env.PORT;
const client = new MongoClient(MONGO_URL); //dial a number.
await client.connect(); //call //previous handshake is happening
console.log("mongo is connected !!!");
app.use('/users',usersRouter) ;
//this route is for dashboard/profile
app.use("/dashboard", profileRouter);
//this route is for allocation page
app.use("/dashboard", allocationRouter);
//this route is for allocation page
app.use("/dashboard", employeeRouter);
app.listen(PORT, () => console.log(`The server started in: ${PORT} ✨✨`));
export { client };