-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.js
More file actions
33 lines (24 loc) · 734 Bytes
/
index.js
File metadata and controls
33 lines (24 loc) · 734 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
27
28
29
30
31
32
33
require('dotenv').config();
const express = require('express');
const helmet = require('helmet');
const cors = require('cors');
const mongoose = require('mongoose');
const auth = require('./auth');
const posts = require('./posts');
const app = express();
// Environment variable for port
const PORT = process.env.PORT;
app.use(helmet());
app.use(cors());
app.use(express.json());
// Use auth endpoint
app.use('/auth', auth);
// Use posts endpoint
app.use('/posts', posts);
mongoose.connect(process.env.DB_CONNECTION, { useNewUrlParser: true, useUnifiedTopology: true }, () => {
console.log('Connected to database!');
})
app.listen(PORT, () => {
console.log(`Server listening on port ${PORT}...`)
})
module.exports = app;