-
Notifications
You must be signed in to change notification settings - Fork 0
/
server.js
44 lines (36 loc) · 1.09 KB
/
server.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
import mongoose from "mongoose"
import bodyParser from "body-parser"
import morgan from "morgan"
import helemt from "helmet"
import express from "express"
import cors from "cors";
import dotenv from "dotenv"
import authRoutes from "./routes/auth.js"
import statsRoutes from "./routes/stats.js"
import transactionRoutes from "./routes/transaction.js"
import corsOptions from "./configs/Corsoptions.js"
// Configs
dotenv.config();
const app = express();
app.use(express.json());
app.use(helemt());
app.use(helemt.crossOriginResourcePolicy({policy:'cross-origin'}));
app.use(morgan('common'));
app.use(bodyParser.json());
app.use(bodyParser.urlencoded({extended:true}));
const corsOption = {
origin: true
};
app.use(cors(corsOption));
// Routesss;
app.get("/",(req,res)=>res.send("connect"))
app.use('/auth',authRoutes)
app.use('/transactions',transactionRoutes);
app.use('/stats',statsRoutes);
// Mongo Connection
const PORT = process.env.PORT || 6008
mongoose.connect(process.env.MONGO_URL)
.then(()=>{
app.listen(PORT,()=>console.log(`Server Port:${PORT}`))
})
.catch((err)=>console.log(err))