Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/yogyy/fastify-roles
fastify RBAC using typescript and postgresql
https://github.com/yogyy/fastify-roles
drizzle-orm fastify jwt postgresql
Last synced: 24 days ago
JSON representation
fastify RBAC using typescript and postgresql
- Host: GitHub
- URL: https://github.com/yogyy/fastify-roles
- Owner: yogyy
- Created: 2024-02-04T08:14:01.000Z (11 months ago)
- Default Branch: main
- Last Pushed: 2024-11-22T17:08:54.000Z (about 1 month ago)
- Last Synced: 2024-11-22T18:23:57.292Z (about 1 month ago)
- Topics: drizzle-orm, fastify, jwt, postgresql
- Language: TypeScript
- Homepage:
- Size: 137 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Multi Tenant Role Based Access Control (RBAC) Authentication API
## Features
- Create an application
- Register a user for an application
- Login
- Create a role
- Assign a role to a user- Check user permissions with a guard
## What are we using?
- [Drizzle ORM](https://github.com/drizzle-team/drizzle-orm)
- [Fastify](https://www.fastify.io/)
- [PostgreSQL](https://www.postgresql.org/)
- [TypeScript](https://www.typescriptlang.org/)## What you'll need
- Node.js - [Download](https://nodejs.org/en/download/)
- A database - [PostgreSQL by Neon](https://bit.ly/tomdoestech)
- A REST client - [Thunder Client](https://marketplace.visualstudio.com/items?itemName=rangav.vscode-thunder-client)## What you will learn
- How to create a multi tenant application
- How to create a role based access control system
- Some basic relational database concepts
- A nice and neat file structure for backend services
- TypeScript
- Fastify
- RESTful API design
- How to use Drizzle ORM## Data structure
## Data flow
## Code structure
1. Setup the initial application
2. Create a database with Neon
3. Create database schemas
4. Run migrations
5. Register an application
6. Register a user
7. Login
8. Create a role
9. Assign a role to a user
10. Check user permissions with a guard## Tips
- Infer the applicationId from the JWT where possible
- Include the applicationId in queries