-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
47 lines (39 loc) · 1.52 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
40
41
42
43
44
45
46
47
import express from 'express';
import cors from 'cors';
import dotenv from "dotenv";
import { mongo } from "./connection.js"
import { dashboardRouter } from "./routers/dashboard.js"
import { printDetailsRouter } from "./routers/printDetails.js"
import { addExpensesRouter } from "./routers/addExpenses.js";
import { expensesListRouter } from './routers/expensesList.js';
import { transferredAmountRouter } from "./routers/transferredAmount.js";
import { signupRouter } from './routers/signup.js';
import { loginRouter } from './routers/login.js';
import { forgotPasswordRouter } from './routers/forgotPassword.js';
import { resetPasswordRouter } from './routers/resetPassword.js';
import { auth } from "./middleware/auth.js";
//env file
dotenv.config();
const app = express();
//middleware
app.use(express.json())
app.use(cors());
//Mongo db connection
mongo();
let PORT = process.env.PORT || 3001;
app.get('/', (req, res) => {
res.send("Hello World!!!")
})
//Authentication
app.use("/signup", signupRouter)
app.use("/login", loginRouter)
app.use("/forgot-password", forgotPasswordRouter)
app.use("/reset-password", resetPasswordRouter)
//Authorization
app.use("/dashboard", auth, dashboardRouter)
app.use("/dashboard/print-details", printDetailsRouter)
app.use("/add-expenses", auth, addExpensesRouter)
app.use("/expenses-list", auth, expensesListRouter)
app.use("/expenses-list/:id", auth, expensesListRouter)
app.use("/transferred-amount", auth, transferredAmountRouter)
app.listen(PORT, () => { console.log("App is running on: " + PORT) });