Documentation
Introduction
Sentro is a powerful Node.js framework that automatically generates type-safe REST APIs from your database schema. It eliminates boilerplate while providing extensive customization for building production-ready database management systems.
Key Features
- Auto-generated REST API - Automatically creates CRUD endpoints for all database tables
- Type-safe - Generates TypeScript types from your database schema
- Multi-database support - Works with PostgreSQL, MySQL, and MSSQL
- Framework agnostic - Integrates with NestJS, Express, Fastify, or runs standalone
- Schema introspection - Automatically reads and understands your database structure
- Extensive customization - Powerful ModelCustomizer API for tailoring behavior
- Hook system - Before/after hooks for intercepting CRUD operations
- Custom actions - Define table and record-level actions for business logic
- Integration registry - Plugin system for third-party services
- Field transformations - Transform field values during create/update operations
What Problems Does It Solve?
Eliminates Boilerplate
Instead of manually writing CRUD endpoints for every table, Sentro introspects your database and automatically generates a complete REST API with pagination, filtering, and search.
Type Safety
Automatically generates TypeScript types for all tables, ensuring compile-time safety when working with your data.
Flexible Customization
The ModelCustomizer API provides hooks, field writers, and custom actions that let you add business logic without modifying the core framework.
Multi-Framework Support
Works seamlessly with popular Node.js frameworks or as a standalone server, giving you flexibility in your architecture.
Architecture Overview
Sentro consists of several key components:
Quick Example
import Connector from "@sentrodb/connector-node";
import ConnectorHelperSql from "@sentrodb/connector-helper-sql";
import { ModelCustomizer } from "@sentrodb/connector-node/dist/inc/customizers/modelCustomizer";
const connector = new Connector({
secretKey: "your-secret-key",
db: {
host: "localhost",
port: 5432,
user: "postgres",
password: "password",
database: "mydb",
type: "postgres"
}
});
// Set database handler
await connector.setDatabaseHandler(new ConnectorHelperSql());
// Customize tables
connector.customize(() => {
const c = new ModelCustomizer("users");
c.rename("System Users");
c.renameColumn("email", "Email Address");
return c;
});
// Start and mount
await connector.start();
connector.mountOnNestJs(app);