Centralized permission and entitlement engine for SaaS applications.
- Node.js (>=18.0.0)
- Express.js
- PostgreSQL
- Drizzle ORM
- Redis (Upstash)
- Clerk Auth
- JavaScript (ES Modules)
- Install dependencies:
npm install- Create
.envfile from.env.example:
cp .env.example .env- Update
.envwith your configuration:DATABASE_URL: PostgreSQL connection stringREDIS_URL: Redis connection stringCLERK_SECRET_KEY: Your Clerk secret key (required for authentication)
Run the development server with nodemon:
npm run devThe server will start on port 3000 (or the port specified in your .env file).
Once the server is running, you can check the health endpoint:
curl http://localhost:3000/health├── config/ # Configuration files (env, db)
├── constants/ # Application constants
├── controllers/ # Route controllers (use asyncHandler)
├── db/ # Database schemas and migrations
├── middlewares/ # Express middlewares (auth, error-handler, etc.)
├── models/ # Data models
├── routes/ # Route definitions
├── services/ # Business logic services
├── utilities/ # Utility functions (logger, errors, validators, async-handler)
└── index.js # Application entry point
All controllers use the asyncHandler wrapper to automatically handle errors. No need for try-catch blocks:
import asyncHandler from '../utilities/async-handler.js';
export const getUsers = asyncHandler(async (req, res) => {
const users = await usersService.getAll();
res.json({ success: true, data: users });
});- Uses
@clerk/expresspackage for authentication - Clerk user IDs are strings, not integers
- Access user via
req.userIdorreq.user(set by auth middleware) - See
controllers/example.controller.jsfor usage examples
- Custom error classes in
utilities/errors.js - Global error handler middleware catches all errors
- Consistent error response format
npm run dev- Start development server with nodemonnpm start- Start production servernpm run db:generate- Generate database migrationsnpm run db:migrate- Run database migrationsnpm run db:push- Push schema changes to databasenpm run db:studio- Open Drizzle Studio
ISC