Node Secrets
Server-side secret management utils for Node.js
Usage
import { GraphQLClient } from 'graphql-request';
import { config } from './config';
import { getSecretFromArn } from './getSecretFromArn';
export const hasuraClient = new GraphQLClient(config.HASURA_ENDPOINT, {
requestMiddleware: async (request) => {
const adminSecret = await getSecretFromArn(config.HASURA_ADMIN_SECRET_ARN);
return {
...request,
headers: {
...request.headers,
'x-hasura-admin-secret': adminSecret,
},
};
},
});
How it works
- Secrets are loaded from AWS Secrets Manager at run time.
- The request value is cached for 10 minutes to optimise request speed and cost.
- Secrets are returned as string values.
- An error is thrown if the secret cannot be found.