-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
31 lines (25 loc) · 894 Bytes
/
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
import express from 'express'
import cors from 'cors'
import dotenv from 'dotenv'
dotenv.config()
import { mongoConnection } from './db.js'
import { userRouter } from './Routes/userRoutes.js'
import { paymentRouter } from './Routes/paymentRoutes.js'
import { productRouter } from './Routes/productRoutes.js'
const app = express();
const PORT = process.env.PORT || 9000;
//DataBase connection
mongoConnection();
//middleware
app.use(cors());
app.use(express.json());
// built-in middleware to handle urlencoded form data
app.use(express.urlencoded({ extended: false }));
//Base Route - Router
app.use('/auth/user', userRouter);
app.use('/api/payment', paymentRouter);
app.use('/products', productRouter);
// Listening to server
app.listen(PORT, () => console.log(`Server running on port ${PORT}`));
// import crypto from 'crypto'
// console.log(crypto.randomBytes(64).toString('hex'));