-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathserver.js
38 lines (30 loc) · 1.06 KB
/
server.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
33
34
35
36
37
require('dotenv').config();
const express = require('express');
const users = require('./routes/api/users');
const kids = require('./routes/api/kids');
const mongoose = require('mongoose');
const bodyparser = require('body-parser');
const passport = require('passport');
const nodemailer = require("nodemailer");
const lodash = require("lodash");
const app = express();
//Body parser configuration
app.use(bodyparser.urlencoded({ extended: false }));
app.use(bodyparser.json());
//First route
app.get('/', (req, res) => res.send(' Hello 1245'));
//Use routes
app.use('/api/users', users);
app.use('/api/kids', kids);
const port = process.env.port || 7200;
app.listen(port, () => console.log(`Server running on port ${port}`));
//Db config
//const db = require('./config/keys').mongoURI;
const db = process.env.DATABASE_URL;
//Connect to MongoDB
mongoose
.connect(db, { useNewUrlParser: true, useUnifiedTopology: true })
.then(() => console.log('CosmosDb Connected'))
.catch((err) => console.log(err));
app.use(passport.initialize());
require('./config/passport')(passport);