@designsystemsinternational/react-github-admin-proxy
v1.0.0
Published
This small proxy function is to be used alongside `@designsystemsinternational/react-github-admin` as a proxy for the OAuth login call. We need this proxy in order to hide the GitHub app secret, and this is impossible on static sites.
Downloads
7
Keywords
Readme
React GitHub Admin Proxy
This small proxy function is to be used alongside @designsystemsinternational/react-github-admin
as a proxy for the OAuth login call. We need this proxy in order to hide the GitHub app secret, and this is impossible on static sites.
This package has only a single function export with the following signature:
authorizeGitHub(client, code);
client
is the GitHub app client IDcode
is the auth code returned from the first step of the GitHub OAuth flow
The function expects an environment variable to be present where the key is set to the GitHub app client ID and the secret is set to the GitHub app client secret. This makes it possible to use this function for more than a single GitHub app.
Deploying
This package has on purpose no server code. It's a simple function with a single dependency, so you can deploy it to AWS Lambda, Netlify cloud functions, Heroku, or any other service.
AWS Lambda
This is the code required to deploy this package to an AWS Lambda:
const proxyGitHub = require("@designsystemsinternational/react-github-admin-proxy");
const handler = async (event) => {
const payload = JSON.parse(event.body);
try {
const res = await proxyGitHub(payload.client, payload.code);
return res;
} catch (e) {
return {
error: e.toString(),
};
}
};
module.exports = {
handler,
};