https://github.com/pointblankdev/lambda-auth
https://github.com/pointblankdev/lambda-auth
Last synced: 11 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/pointblankdev/lambda-auth
- Owner: pointblankdev
- Created: 2021-06-08T02:02:28.000Z (about 5 years ago)
- Default Branch: master
- Last Pushed: 2021-11-23T20:26:49.000Z (over 4 years ago)
- Last Synced: 2023-03-04T02:37:49.105Z (over 3 years ago)
- Language: JavaScript
- Size: 489 KB
- Stars: 0
- Watchers: 2
- Forks: 1
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# lambda-auth
## Usage
Use lambda-auth to `verify()` RS256 JWTs and decode their accessToken.
```ts
const { verify } = require('@pointblankdev/lambda-auth');
const server = new ApolloServer({
schema: buildFederatedSchema([{ typeDefs, resolvers }]),
context: async ({ event, context }) => {
return {
headers: event.headers,
functionName: context.functionName,
event,
context,
user: await verify(event),
};
},
playground: {
endpoint: `/${process.env.ENV}/graphql`,
},
introspection: true,
});
```
## Notes
The verify function is asynchronous so you can either await the function like it's been done above or `await context.user` whenever you want to access it