-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.ts
53 lines (40 loc) · 1.71 KB
/
index.ts
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
48
49
50
51
52
53
import express from 'express';
import bodyParser from 'body-parser';
import mongoose from 'mongoose';
import cors from 'cors';
import forgotPasswordRouter from './routes/forgotPasswd';
import vendorRouter from './routes/vendor';
import customerRouter from './routes/customer';
import adminRouter from './routes/admin';
// For the MongoDB connection
import connectDB from './config/db';
import CPUConfigRouter from './routes/cpuConfig';
const app = express();
// MongoDB Atlas Connection
connectDB();
app.use(bodyParser.json({ limit: '30mb', extended: true } as { limit: string; extended: boolean }));
app.use(bodyParser.urlencoded({ limit: '30mb', extended: true }));
app.use(cors());
app.get('/', (req, res, next) => {
res.send('Sample Route to Test the Backend Setup');
});
// --------------- ROUTES ------------------------------- //
// Routes For Vendor
app.use('/api/forgotPassword', forgotPasswordRouter);
// Routes For Vendor
app.use('/api/vendor', vendorRouter);
// Routes For Customer
app.use('/api/customer', customerRouter);
// Routes For Admin
app.use('/api/admin', adminRouter);
// Routes For Admin
app.use('/api/cpuConfig', CPUConfigRouter);
// MONGOOSE SAMPLE CONNECTION
// // LATER TO BE STORED IN ENV
// const CONNECTION_URL = 'mongodb+srv://inderpreetmongo:[email protected]/myFirstDatabase?retryWrites=true&w=majority'
// const PORT = process.env.PORT || 5000;
// mongoose.connect(CONNECTION_URL, {useNewUrlParser: true, useUnifiedTopology: true})
// .then(() => app.listen(PORT, () => console.log(`Server runnng on ${PORT}`)))
// .catch((error) => console.log(error.message));
const PORT = process.env.PORT || 5000;
app.listen(PORT, () => console.log(`Server runnng on ${PORT}`));