-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathapp.js
31 lines (29 loc) · 868 Bytes
/
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
const express=require('express');
const app=express();
const mongoose=require('mongoose');
const {mongoURL}=require('./keys')
const cors=require('cors')
const path=require('path')
app.use(cors())
app.use(express.json())
mongoose.connect(mongoURL)
require('./models/userModel')
require('./models/contentModel')
mongoose.connection.on('connected',()=>{
console.log('Connected to mongodb')
})
mongoose.connection.on('error',()=>{
console.log('Couldnt connect to mongodb')
})
app.use(require('./routes/auth'))
app.use(require('./routes/createPodcasts'))
app.use(express.static(path.join(__dirname,'./frontend/build')))
app.get('*',(req,res)=>{
res.sendFile(path.join(__dirname,'./frontend/build/index.html')),
function(err){
res.status(500).send(err)
}
})
app.listen(5000||process.env.port,()=>{
console.log('Server is active....')
})