-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathserver.js
38 lines (33 loc) · 1.1 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
38
///// DEPENDENCIES /////
const express = require('express');
const app = express();
const mongoose = require('mongoose');
const mongoUri = process.env.MONGODB_URI || 'mongodb://localhost:27017/cocktails';
const session = require('express-session');
///// PORT /////
const port = process.env.PORT || 3000;
///// MIDDLEWARE /////
app.use(express.urlencoded({ extended: false }))
app.use(express.json());
app.use(express.static('public'));
app.use(session({
secret:'feedmeseymour',
resave: false,
saveUninitialized: false
}));
// CONTROLLERS
const cocktailsController = require('./controllers/cocktails.js');
app.use('/cocktails', cocktailsController);
const sessionsController = require('./controllers/sessions.js');
app.use('/sessions', sessionsController);
const userController = require('./controllers/users.js')
app.use('/users', userController);
///// LISTENER /////
app.listen(port, () => {
console.log('Listening on port:', port);
})
///// CONNECTIONS /////
mongoose.connect(mongoUri, { useNewUrlParser: true });
mongoose.connection.on('open', () => {
console.log('connected to mongoose!!!!!!!!');
});