-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathapp.js
24 lines (20 loc) · 748 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
//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")
// Express configuration
var app = express()
app.use(bodyParser())
app.use(expressValidator())
app.use(passport.initialize())
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")