-
Notifications
You must be signed in to change notification settings - Fork 6
/
app.js
26 lines (22 loc) · 841 Bytes
/
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
//Module dependencies
var express = require('express')
, http = require('http')
, passport = require('passport')
, util = require('util')
, bodyParser = require('body-parser')
, expressValidator = require('express-validator')
, auth = require("./auth")
, oauth = require("./oauth")
, registration = require("./registration")
// Express configuration
var app = express()
app.use(bodyParser())
app.use(expressValidator())
app.use(passport.initialize())
app.post('/users', registration.registerUser)
app.post('/oauth/token', oauth.token)
app.get('/restricted', passport.authenticate('accessToken', { session: false }), function (req, res) {
res.send("Yay, you successfully accessed the restricted resource!")
})
//Start
http.createServer(app).listen(process.env.PORT || 3000, process.env.IP || "0.0.0.0")