Introducing Crudora - The Ultimate CRUD Framework for Express.js Developers
Discover Crudora, a powerful TypeScript-based CRUD framework built on top of Express.js and Prisma. With zero configuration, automatic API generation, and advanced features like lifecycle hooks and field security, Crudora empowers developers to build REST APIs faster than ever before.
Overview
Building RESTful APIs can be time-consuming, especially when you need to handle repetitive tasks like CRUD operations, validation, pagination, and database interactions. That’s where Crudora comes in—a revolutionary framework designed to streamline API development for TypeScript and Express.js developers.
Crudora is an automatic CRUD API generator that integrates seamlessly with Prisma ORM to help you build robust APIs in minutes, not hours. Whether you’re working on a small project or a large-scale application, Crudora’s rich feature set ensures you stay productive without sacrificing flexibility or performance.
In this article, we’ll explore what makes Crudora stand out, its key features, and how you can get started with it today.
Why Choose Crudora?
Crudora is more than just another CRUD library—it’s a complete solution for modern API development. Here’s why you should consider using Crudora:
1. Zero Configuration
With Crudora, there’s no need to spend hours setting up boilerplate code. Simply install the package, define your models, and let Crudora handle the rest. It automatically generates CRUD endpoints, Prisma schemas, and even environment configurations.
2. Type-Safe Development
Crudora leverages TypeScript and Prisma to provide full type safety throughout your project. This means fewer runtime errors and better developer experience as your IDE provides intelligent autocompletion and error checking.
3. Built-In Features
From automatic request validation with Zod to smart pagination, filtering, and field security, Crudora eliminates the need for third-party libraries by bundling essential tools right out of the box.
4. Lifecycle Hooks
Need to hash passwords before saving them to the database? Or send welcome emails after creating a user? Crudora supports comprehensive lifecycle hooks (beforeCreate, afterUpdate, etc.) to give you fine-grained control over every step of the CRUD process.
5. Extensibility
While Crudora automates most tasks, it doesn’t lock you into a rigid structure. You can easily add custom routes, middleware, and even override default behaviors to suit your specific needs.
Key Features
Here’s a closer look at some of Crudora’s standout features:
🚀 Automatic CRUD Generation
Define your models, register them with Crudora, and watch as it generates fully functional REST endpoints for listing, creating, updating, and deleting records.
class User extends Model {
static tableName = "users";
static fillable = ["name", "email", "password"];
static hidden = ["password"];
}
const server = new CrudoraServer({ port: 3000, prisma });
server.registerModel(User).generateRoutes().listen(); 🔧 Flexible Model Definitions
Crudora allows you to define models with attributes like fillable (for mass assignment), hidden (to exclude sensitive fields from responses), and timestamps (to automatically manage createdAt and updatedAt fields).
📊 Smart Pagination & Filtering
Built-in support for pagination (skip, take) and filtering (where, orderBy) ensures your APIs are scalable and performant.
🛡️ Automatic Validation
Crudora uses Zod under the hood to validate incoming requests. It generates both strict (for creation) and partial (for updates) validation schemas based on your model definitions.
🔒 Field Security
Sensitive fields like passwords or API keys can be marked as hidden, ensuring they’re never exposed in API responses.
⚡ CLI Tool
Crudora includes a powerful CLI for managing your project lifecycle—from initializing projects to running migrations and starting Prisma Studio.
# Initialize a new project
npx crudora init
# Generate Prisma Client
npx crudora generate
# Push schema changes to the database
npx crudora push Getting Started with Crudora
Setting up Crudora is incredibly straightforward. Follow these steps to create your first API:
Step 1: Install Dependencies
npm install crudora prisma @prisma/client
# or
yarn add crudora prisma @prisma/client Step 2: Define Your Models
Create model classes that extend Crudora’s Model base class. For example:
import { Model } from "crudora";
class User extends Model {
static tableName = "users";
static primaryKey = "id";
static timestamps = true;
static fillable = ["name", "email", "password"];
static hidden = ["password"];
static async beforeCreate( any): Promise<any> {
data.password = await hashPassword(data.password);
return data;
}
} Step 3: Register Models and Start the Server
import { CrudoraServer } from "crudora";
import { PrismaClient } from "@prisma/client";
const prisma = new PrismaClient();
const server = new CrudoraServer({
port: 3000,
prisma,
});
server
.registerModel(User)
.generateRoutes()
.listen(() => {
console.log("Server running on port 3000");
}); That’s it! Crudora will automatically generate REST endpoints for your User model.
Advanced Usage
Custom Routes
Need additional functionality beyond CRUD? Crudora makes it easy to add custom routes:
server.get("/health", (req, res) => {
res.json({ status: "ok", timestamp: new Date() });
}); Lifecycle Hooks
Implement lifecycle hooks to execute custom logic during CRUD operations:
static async beforeCreate(data: any): Promise<any> {
data.password = await hashPassword(data.password);
return data;
}
static async afterCreate( any, result: any): Promise<any> {
await sendWelcomeEmail(result.email);
return result;
} Schema Generation
Generate Prisma schemas programmatically based on your models:
const schema = server.getCrudora().generatePrismaSchema("postgresql");
console.log(schema); Conclusion
Crudora is a game-changer for developers looking to accelerate their API development workflow. By combining the power of TypeScript, Express.js, and Prisma, Crudora offers a seamless, type-safe, and highly customizable solution for building RESTful APIs.
Whether you’re a solo developer or part of a larger team, Crudora’s intuitive design and extensive feature set make it an invaluable tool for any project. Give it a try today and experience the joy of effortless API creation!
For more details, check out the official documentation.
⚠️ Note: Crudora is currently in alpha version and may not be suitable for production use. Contributions and feedback are welcome!