-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.js
39 lines (33 loc) · 1.3 KB
/
app.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
const express = require('express');
const cors = require('cors');
const cookieParser = require('cookie-parser');
const bodyParser = require('body-parser');
require('dotenv').config();
const port = process.env.PORT || 4000;
const searchRoute =require('./routes/search')
const makePostRoute = require('./routes/makepPost')
const getPostRoute = require('./routes/getPost')
const userRoute =require('./routes/user')
const deletePostRoute=require('./routes/deletePost')
const addLikeRoute=require('./routes/addLike')
const addCommentRoute=require('./routes/addComment')
const app = express();
app.use(express.static(__dirname + '/public'));
app.use(cors());
app.use(cookieParser());
app.use(bodyParser.json())
app.use(function (req, res, next) {
res.header("Access-Control-Allow-Origin", "https://musicjournal.herokuapp.com"); // update to match the domain you will make the request from
res.header("Access-Control-Allow-Headers", "Origin, X-Requested-With, Content-Type, Accept");
next();
});
app.use("/search",searchRoute);
app.use("/makepost", makePostRoute);
app.use("/getpost", getPostRoute);
app.use("/user",userRoute);
app.use("/deletePost", deletePostRoute);
app.use("/addLike", addLikeRoute);
app.use("/addComment",addCommentRoute);
app.listen(port, () => {
console.log(`server running on ${port}`);
})