-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathserver.js
44 lines (35 loc) · 1.16 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
39
40
41
42
43
44
var express = require('express'),
bodyParser = require('body-parser'),
logger = require('morgan'),
userRouter = require('./routers/user_router.js'),
checkupRouter = require('./routers/checkup_router.js'),
sessionRouter = require('./routers/session_router.js'),
currentUserRouter = require('./routers/current_user_router.js'),
searchRouter = require('./routers/search_router.js'),
session = require('express-session'),
app = express();
if (process.env.NODE_ENV !== 'test') {
app.use( logger('dev') );
}
app.use(bodyParser.json());
app.use(bodyParser.urlencoded({ extended: false }));
app.use(express.static('./public'));
app.use(session({
secret: 'secretsarenofun',
resave: false,
saveUninitialized: true
}));
// Current User
app.use('/current_user', currentUserRouter);
// Users
app.use('/users', userRouter);
// Checkups
app.use('/checkups', checkupRouter);
// Sessions
app.use('/sessions', sessionRouter);
// Search API
app.use('/search', searchRouter);
app.listen(process.env.PORT || 3000, function() {
console.log('Server running on port 3000...');
});
module.exports = app;