-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.js
44 lines (34 loc) · 1.16 KB
/
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
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
"use strict";
var app = require("express")();
var swaggerTools = require("swagger-tools");
var YAML = require("yamljs");
var swaggerConfig = YAML.load("./api/swagger/swagger.yaml");
const cors = require('cors');
const jwt = require('express-jwt');
const jwksRsa = require('jwks-rsa');
const authenticate = jwt({
// Dynamically provide a signing key based on the kid in the header and the singing keys provided by the JWKS endpoint.
secret: jwksRsa.expressJwtSecret({
cache: true,
rateLimit: true,
jwksRequestsPerMinute: 5,
jwksUri: `https://digiglu.eu.auth0.com/.well-known/jwks.json`
}),
// Validate the audience and the issuer.
aud: 'http://localhost:10510/v1/',
iss: `https://digiglu.eu.auth0.com/`,
algorithms: ['RS256']
});
swaggerTools.initializeMiddleware(swaggerConfig, function(middleware) {
app.use( cors() );
app.use( authenticate );
app.use(middleware.swaggerMetadata());
var routerConfig = {
controllers: "./api/controllers",
useStubs: false
};
app.use(middleware.swaggerRouter(routerConfig));
app.listen(process.env.SRV_PORT, function() {
console.log("Started server on port", process.env.SRV_PORT);
});
});