-
Notifications
You must be signed in to change notification settings - Fork 25
/
app.js
45 lines (36 loc) · 1.15 KB
/
app.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
45
var express = require('express');
var cors = require('cors');
var morgan = require('morgan');
var path = require('path');
var marked = require('marked');
var fs = require('fs');
var logger = require('winston');
var userController = require('./controllers/users');
var app = express();
// Add middleware
app.use(cors());
app.use(express.static(path.join(__dirname, 'public')));
app.use(morgan('dev'));
app.set('views', path.join(__dirname, 'views'));
app.set('view engine', 'ejs');
app.get('/', function(req, res, err) { // eslint-disable-line no-unused-vars
var md = function(filename) {
var path = __dirname + "/" + filename;
var include = fs.readFileSync(path, 'utf8');
var html = marked(include);
return html;
};
return res.render('index.ejs', {
"md": md
});
});
// See the User Controller for `/users` routes
app.use('/users', userController);
// Some switches for acceptance tests
if (require.main === module) {
// Only listen when app.js is run - acceptance tests will listen on another port
app.listen(8000, function() {
logger.info('Listening at http://localhost:8000 - see here for API docs');
});
}
module.exports = app;