-
Notifications
You must be signed in to change notification settings - Fork 0
/
server.js
45 lines (36 loc) · 1.22 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
45
const express=require("express");
const app=express();
const mongoose=require('mongoose');
const dotenv=require("dotenv");
const helmet=require("helmet");
const morgan=require("morgan");
const cors=require("cors");
const userRoute=require("./routes/users");
const authRoute=require("./routes/auth");
const postRoute=require("./routes/posts");
const companyRoute=require("./routes/companies");
// const passwordResetRoutes = require("./routes/passwordReset");
dotenv.config();
mongoose.connect(process.env.MONGO_URL,err=>{
if(err) throw err;
console.log('conneted to mongodb')
})
//middleware
app.use("/static",express.static("./uploads"))
app.use(express.json());
app.use(helmet());
app.use(morgan("common"));
app.use(cors());
app.use("/api/users", userRoute);
app.use("/api/auth",authRoute);
app.use("/api/posts",postRoute);
app.use("/api/company",companyRoute);
// app.use("/api/password-reset", passwordResetRoutes);
app.get("/",(req,res)=>{
res.send("welcome to home page")
})
app.listen(8081,()=>{
console.log("Server started on port 8081");
})
// Helmet helps you secure your Express apps by setting various HTTP headers. It's not a silver bullet, but it can help!
// Morgan: HTTP request logger middleware for node.js