-
Notifications
You must be signed in to change notification settings - Fork 5
/
index.js
30 lines (22 loc) · 784 Bytes
/
index.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
var express = require('express'),
morgan = require('morgan'),
mongoose = require('mongoose'),
bodyParser = require('body-parser'),
AuthController = require('./controllers/auth_controller');
var app = express();
var router = express.Router();
mongoose.connect('mongodb://localhost:testOauth/testOauth')
var protectedAction = function(req, res) {
res.send("Here's some protected information!");
}
router.route('/facebook_auth')
.post(AuthController.facebookAuth);
router.route('/protected')
.get([AuthController.requireAuth, protectedAction]);
app.use(morgan('combined'));
app.use(bodyParser.json({type:'*/*'}));
app.use('/v1', router);
app.listen(3000, function(err) {
if (err) { return console.log(err); }
console.log("Listening on port 3000.");
});