forked from s-bhalode/creatify-backend
-
Notifications
You must be signed in to change notification settings - Fork 0
/
server.js
47 lines (34 loc) · 1.05 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
const express = require('express');
const bodyParser = require('body-parser');
const cors = require('cors');
const dotenv = require('dotenv');
const mongoose = require('mongoose');
const mongoClient = require('mongodb').mongoClient;
const app = express();
dotenv.config({path : './config.env'});
const PORT = process.env.PORT;
app.use(bodyParser.json());
app.use(bodyParser.urlencoded({extended : true}));
app.use(cors(corsOptions));
app.use(express.json());
app.use(express.urlencoded({extended : true}));
require('./src/config/dbConnection');
require('./src/config/cloudinary');
app.use((req, res, next) => {
res.header(
"Access-Control-Allow-Headers",
"x-access-token, Origin, Content-type, Accept"
);
next();
});
var corsOptions = {
origin : "http://localhost:3000"
};
//routes
require("./src/routes/auth.routes")(app);
require("./src/routes/user.routes")(app);
// const PORT = process.env.PORT || 5050;
app.listen(PORT, () => {
console.log(`server is running at port ${PORT}`);
})
module.exports = app;