This is a Node.js backend application that implements a basic access control system. It allows users, groups, and resources to interact through a flexible permission-sharing model.
-
Users can belong to multiple groups
-
Resources can be shared with:
- Specific users
- Groups
- Everyone (public access)
-
CRUD operations for Users, Groups, and Resources
-
Access control enforcement
- Node.js with Express.js
- PostgreSQL via Prisma ORM
- TypeScript for static typing
- Jest for testing
git clone https://github.com/samicey/resource-access-api.git
cd resource-access-apinpm installCreate a .env file:
DATABASE_URL=""
SHADOW_DATABASE_URL=""npm run prisma:generate
npx prisma:migrate npm run devPOST /user– Create a userGET /user– List all usersGET /user/:id– Get user by IDGET /user/:id/resources– Get all resources that user have access to
POST /group– Create a groupGET /group– List all groups
POST /resource– Create a resource with accessGET /resource– List all resourcesPATCH /resource/:id– Update resource accessGET /resource/:id/access-list– Get all users with access
npm testTests are written using Jest and mock Prisma repositories and service dependencies.
- Implementing the optional requirements for aggregation and analysis.
- more tests especially integration test
- Have response handler that will reduce code duplication
- add validations with zod for user validation
- API rate limiting & authentication