- Finish cleanup

Signed-off-by: Dave Richer <dave@imexsystems.ca>
This commit is contained in:
Dave Richer
2024-01-23 00:02:18 -05:00
parent a162b275a3
commit 52f8eabd2b
22 changed files with 1033 additions and 1045 deletions

View File

@@ -0,0 +1,24 @@
const {GraphQLClient} = require("graphql-request");
/**
* Middleware to add a GraphQL Client to the request object
* Adds the following to the request object:
* req.userGraphQLClient - GraphQL Client with user Bearer Token
* req.BearerToken - Bearer Token
* @param req
* @param res
* @param next
*/
const withUserGraphQLClientMiddleware = (req, res, next) => {
const BearerToken = req.headers.authorization;
req.userGraphQLClient = new GraphQLClient(process.env.GRAPHQL_ENDPOINT, {
headers: {
Authorization: BearerToken,
},
});
req.BearerToken = BearerToken;
next();
};
module.exports = withUserGraphQLClientMiddleware;