Skip to content

Commit

Permalink
cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
sgalvagno committed Sep 23, 2024
1 parent ad20024 commit f4be2b2
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions app.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ const app = express();
// const apiSpec = path.join(__dirname, 'api.yaml');
const apiSpec = path.join(__dirname, 'zooprocess.openapi.yaml');


function verifyToken (req, res, next){

console.log("verifyToken middleware")
Expand All @@ -38,6 +39,7 @@ function verifyToken (req, res, next){
}
}


function extractJWT(req, res, next){

if ( req.token ){
Expand Down Expand Up @@ -206,27 +208,36 @@ async function getRole(req, res, next){
// return handler[method];
// }

// console.log("modulePathResolverSeb ok")
var corsOption = {
origin: 'http://zooprocess.imev-mer.fr',
optionSuccessStatus: 200 // for legacy browser
}
// app.use (cors(corsOption))
app.use(cors())

// console.log("cors ok")

// 1. Install bodyParsers for the request types your API will support
app.use(express.urlencoded({ extended: false }));
app.use(express.text());
app.use(express.json());

// console.log("bodyParsers ok")

app.use(logger('dev'));

// console.log("logger ok")

app.use('/spec', express.static(apiSpec));

app.use(verifyToken)
app.use(extractJWT)
app.use(getRole)
// app.use(isRoleAllowed)

// console.log("verifyToken ok")

// 2. Install the OpenApiValidator middleware
app.use(
openApiMiddleware({
Expand Down

0 comments on commit f4be2b2

Please sign in to comment.