forked from auth0/nginx-jwt
-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathserver.js
32 lines (24 loc) · 783 Bytes
/
server.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
var express = require('express');
var morgan = require('morgan');
var app = express();
app.use(morgan('combined'));
app.get('/', function (req, res) {
res.send('Backend API root');
});
app.get('/secure', function (req, res) {
console.log('Authorization header:', req.get('Authorization'));
res.json({
message: 'This endpoint needs to be secure.'
});
});
app.get('/secure/admin', function (req, res) {
console.log('Authorization header:', req.get('Authorization'));
res.json({
message: 'This endpoint needs to be secure for an admin.'
});
});
var server = app.listen(5000, function () {
var host = server.address().address;
var port = server.address().port;
console.log('App listening at http://%s:%s', host, port);
});