0.0.3 ā¢ Published 3 years ago
core-lib-iam-grpc-client v0.0.3
core-lib-iam-grpc-client auth module in Javascript
š Homepage
Prerequisites
- npm >= 6.14.9
- node >= 14.15.3
- Dependencies
- @grpc/grpc-js": "^1.3.7"
- @grpc/proto-loader": "^0.6.4"
- Environments
- process.env.IAM_GRPC_HOST
- process.env.IAM_GRPC_PORT
Install
npm install core-lib-iam-grpc-client
Usage
(In src/middlewares/auth.js)
const { requestIamAuth } = require('core-lib-iam-grpc-client');
const auth = (apiId) => async (req, res, next) => {
return requestIamAuth('ACCESS_TOKEN_from_req.headers', apiId)
.then(() => next())
.catch((error) => {
res.status(error.statusCode).send({
message: error.message,
errorInfo: {
code: error.errorCode,
message: error.message,
},
});
});
};
Author
š¤ WELT Corp.