-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.js
More file actions
52 lines (37 loc) · 1.31 KB
/
app.js
File metadata and controls
52 lines (37 loc) · 1.31 KB
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
46
47
48
49
const express = require("express");
const app = express();
const PORT = process.env.PORT || 5000;
const bodyParser = require("body-parser");
const cors = require("cors");
require('dotenv').config();
// "proxy": "http://localhost:8080"
// "heroku-postbuild": "NPM_CONFIG_PRODUCTION=false npm install --prefix client && npm run build --prefix client"
//db connection
require("./models/db");
app.use(cors());
app.use(bodyParser.json());
app.use(bodyParser.urlencoded({ extended: true }));
//router
app.use("/auth", require("./router/user"));
app.use("/auth", require("./router/post"));
app.use("/auth", require("./router/announcement"));
app.use("/auth", require("./router/profile"));
//to deploy heroku
// Serve static assets if in production
// if (process.env.NODE_ENV === 'production') {
// app.use(express.static('client/build'));
// app.get('*', (req, res) => {
// res.sendFile(path.resolve(__dirname, 'client', 'build', 'index.html'));
// });
// }
//to deploy vercel
// if(process.env.NODE_ENV=='production'){
// const path = require('path')
// app.get('/',(req,res)=>{
// app.use(express.static(path.resolve(__dirname,'client','build')))
// res.sendFile(path.resolve(__dirname,'client','build','index.html'))
// })
// }
app.listen(PORT, (req, res) => {
console.log("Server connected");
});