Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

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

Awesome Lists containing this project

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 channel

Zero To Shipped

Make 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