forked from panzerox123/ProjectManager
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
32 lines (24 loc) · 1.05 KB
/
index.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
const express = require('express');
const mongoose = require('mongoose');
const config = require('config');
const cors = require('cors');
const app = express();
const PORT = process.env.PORT || 8000;
const userRoute = require('./routes/user.route');
const teamsRoute = require('./routes/teams.route');
const tasksRoute = require('./routes/tasks.route');
app.use(cors({exposedHeaders: ['x-auth-token']}));
app.use(express.json());
app.use(express.urlencoded({extended: true}));
if(!config.get("private_key")){
console.error("Key error");
process.exit(1);
} else {
//console.log("Private key defined");
}
app.get('/', (req,res)=> res.status(200).send(`Node backend for Project Management App running on ${PORT}`));
mongoose.connect('mongodb://localhost/project_manager', {useNewUrlParser: true, useUnifiedTopology: true}).then(()=>console.log("Connected to MongoDB")).catch(err=>{throw err});
app.use('/api/auth', userRoute);
app.use('/api/teams',teamsRoute);
app.use('/api/tasks',tasksRoute);
app.listen(PORT, (console.log(`Server running on port ${PORT}`)));