Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/kitze/graphql-user
Reusable utility methods for GraphQL authentication in Node.js
https://github.com/kitze/graphql-user
Last synced: about 2 months ago
JSON representation
Reusable utility methods for GraphQL authentication in Node.js
- Host: GitHub
- URL: https://github.com/kitze/graphql-user
- Owner: kitze
- Created: 2019-05-27T07:26:04.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2023-05-25T15:04:56.000Z (over 1 year ago)
- Last Synced: 2024-04-21T23:56:29.691Z (5 months ago)
- Language: TypeScript
- Homepage: https://www.npmjs.com/package/graphql-user
- Size: 1.64 MB
- Stars: 104
- Watchers: 4
- Forks: 3
- Open Issues: 17
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
- awesome-list - graphql-user
README
## 👩✈️ graphql-user
This package is using the packages `bcrypt` and `jsonwebtoken` in order to provide some reusable functions for GraphQL authentication.
### 🙋♂️ Made by [@thekitze](https://twitter.com/thekitze)
### Other projects:
- 🏫 [React Academy](https://reactacademy.io) - Interactive React and GraphQL workshops
- 💌 [Twizzy](https://twizzy.app) - A standalone app for Twitter DM
- 💻 [Sizzy](https://sizzy.co) - A tool for testing responsive design on multiple devices at once
- 🤖 [JSUI](https://github.com/kitze/JSUI) - A powerful UI toolkit for managing JavaScript apps
- 🎥 [Vlog](https://youtube.com/kitze) - My YouTube channelMake sure that your app has an `APP_SECRET` env variable.
It includes the [following functions](https://github.com/kitze/graphql-user/blob/master/src/index.ts):
- `getUserId(context): string` - Returns the id from the currently logged-in user `context.request.get("Authorization")`
- `getToken(userId: string): string` - Returns a token by signing an object containing `{userId}` using the `APP_SECRET`
- `getHashedPassword(password: string): string` - Returns a hashed version of a password
- `comparePassword(password: string, comparePassword:string): boolean` - Compares a password and a hashed password