-
-
Save christophetd/26c3579625d742cd94664a80e6feb603 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var express = require('express'); | |
var config = require('./config'); | |
var controller = require('./helpers/controller.js'); | |
var authMiddleware = require('./middlewares/AuthMiddleware'); | |
var loggerMiddleware = require('./middlewares/LoggerMiddleware'); | |
var bodyParser = require('body-parser'); | |
require('mongoose').connect(config.mongoUri); | |
var app = express(); | |
app.use(loggerMiddleware); | |
app.use(bodyParser.json()); | |
app.use('/api/auth', controller('auth')); | |
app.use(authMiddleware); | |
app.use('/api/demo', controller('demo')); | |
app.use('/api/user', controller('user')); | |
app.use('/api/activities', controller('activities')); | |
var port = process.env.PORT || config.port; | |
app.listen(port, function () { | |
console.log("Application listening on port %s", port); | |
}); | |
/* Extra code from controller.js */ | |
function capitalizeFirstLetter(string) { | |
return string.charAt(0).toUpperCase() + string.slice(1); | |
} | |
module.exports = function (name) { | |
return require('./../controllers/'+capitalizeFirstLetter(name)+'Controller'); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment