-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathserver.js
More file actions
26 lines (19 loc) · 691 Bytes
/
Copy pathserver.js
File metadata and controls
26 lines (19 loc) · 691 Bytes
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
import express from 'express'
import mongoose from 'mongoose'
import keys from './config/keys.js'
import users from './routes/api/users.js'
import profile from './routes/api/profile.js'
import posts from './routes/api/posts.js'
const app = express()
// Connect Mongo DB
const db = keys.mongoURI
mongoose
.connect(db)
.then(() => console.log('MongoDB connected'))
.catch(err => console.log(`MongoDB failed to connect : ${err}`))
app.get('/', (req, res) => res.send("Hello World"))
app.use('/api/users', users)
app.use('/api/profile', profile)
app.use('/api/posts', posts)
const port = process.env.PORT || 5000
app.listen(port, () => console.log(`Server running on port ${port}`))