From 2305bca7265eb32e03d2f1d173fd80ecb0c287a9 Mon Sep 17 00:00:00 2001 From: Abhishek Chatterjee Date: Wed, 25 Nov 2026 20:46:23 +0530 Subject: [PATCH 1/2] chore(ross-docs): #255: update intro and programmatic usage docs --- ross/docs/docs/intro.mdx | 93 +++++++++------------------------- ross/docs/docs/programmatic.md | 29 ++++++----- 2 files changed, 40 insertions(+), 82 deletions(-) diff --git a/ross/docs/docs/intro.mdx b/ross/docs/docs/intro.mdx index caa660a9..2fba8169 100644 --- a/ross/docs/docs/intro.mdx +++ b/ross/docs/docs/intro.mdx @@ -9,50 +9,38 @@ slug: / ROSS API Framework Logo

-ROSS is a configuration-driven API framework designed to accelerate backend development by automating standard engineering tasks. By defining models in a structured JSON format, ROSS automatically handles database schema generation, RESTful routing, request validation, and interactive documentation. +ROSS is an open-source, configuration-driven REST API framework based on Fastify. Instead of writing repetitive boilerplate for models, routes, validation, and docs, you declare your application in a single structured configuration and ROSS handles database schema management, CRUD/search/aggregate endpoints, request validation, authentication, RBAC, caching, outbound webhooks, and interactive OpenAPI/Swagger documentation automatically. -## Features +## Two Ways to Use ROSS -- **Automated API Generation**: Instant creation of CRUD, Search, and Aggregate endpoints from JSON configurations. -- **Database Schema Management**: Automatic handling of table creation, multi-column indexes, and foreign key constraints. -- **Multi-Engine Database Support**: Native support for both PostgreSQL and SQLite. -- **Interactive Documentation**: Integrated Swagger/OpenAPI UI available at the specified documented path. -- **Robust Validation**: Driven by AJV (JSON Schema) for strict and customizable request validation. -- **Advanced Querying**: Native support for filtering, sorting, and complex search operations. +You can run ROSS as a standalone CLI over a JSON file or use it programmatically in your Node.js/TypeScript code. -## Quick Start +### CLI (`ross`) -### 1. Installation +Point the CLI at a `ross.json` configuration file and let ROSS manage the full server lifecycle—no application code required. -Clone the repository and install dependencies: +- **Zero boilerplate**: Define models, auth, caching, and custom SQL/function endpoints in JSON and boot immediately with `ross dev` or `ross start`. +- **Built-in tooling**: Validate configs (`ross config validate`), inspect resolved defaults with secrets redacted (`ross config show`), and run schema/custom migrations (`ross migrate`). +- **Best for**: Rapid prototyping, standard CRUD/data APIs, and teams that want a declarative backend without maintaining server glue code. -```bash -git clone https://github.com/imdeepmind/rocket.git -cd rocket -npm install -``` - -### 2. Initialize the Server - -Start the server using an existing configuration file: +See the [Getting Started](./get-started.md) guide and [CLI Reference](./cli.md). -```bash -ross dev -c example_config.json -``` +### Programmatic (`@imdeepmind/ross`) -### 3. API Exploration +Import `createServer`, `defineConfig`, and `migrateDatabase` directly into your Node.js or TypeScript codebase while keeping full control of the Fastify instance. -Once the server is initialized, refer to the Swagger UI for interactive API documentation: -[http://localhost:3000/api/docs](http://localhost:3000/api/docs) +- **Type-safe configuration**: Author configs in TypeScript using `AppConfigInput` and split large setups across multiple modules. +- **Full Fastify control**: Attach custom hooks, plugins, or routes, and decide when to call `app.listen()` and `app.close()`. +- **Test-friendly**: Exercise routes in-process with `app.inject()` without binding a network port. +- **Best for**: Existing Fastify services, custom middleware/business logic, and TypeScript-first projects. +See [Programmatic Usage](./programmatic.md). +## Barebone Example -## 01 Barebone Configuration +The smallest configuration that boots a working API needs only `application.name` and `data.models`: -The smallest config that boots a working API needs only an application name -and one model: - -```json +```json title="ross.json" { "application": { "name": "Barebone API" }, "data": { @@ -69,45 +57,14 @@ and one model: } ``` -```bash -ross dev -c examples/01-barebone/barebone_config.json -``` - -The single model exposes `POST /api/v1/notes/`, `GET /api/v1/notes/`, -`GET /api/v1/notes/id/:id`, `GET /api/v1/notes/search/title`, -`PATCH`/`PUT /api/v1/notes/title/:title`, and -`PATCH`/`DELETE /api/v1/notes/status/:status` on a dev SQLite database, -with Swagger at `/docs`. - -## Configuration defaults - -ROSS resolves your configuration before validating it. Only -`application.name` and `data.models` are required — omitted sections receive -defaults: - -- docs are enabled in `dev` and disabled in `prod` -- the dev database defaults to SQLite (`./database.db`); `prod` requires - `infrastructure.database` -- the cache defaults to in-memory; configure `infrastructure.cache` with Redis or Memcached when you need a shared cache -- authentication defaults to disabled -- rate limiting defaults to disabled (`100 requests / 1m`) -- CORS defaults to disabled -- the API variant defaults to `v1` - -Inspect the fully resolved configuration (with secrets redacted) before -starting the server: +Start the development server: ```bash -ross config show -c config.json +ross dev -c ross.json ``` -## Technology Stack +With that single model, ROSS sets up a local SQLite database (`./database.db`), mounts REST endpoints under `/api/v1/notes` (`POST`, `GET`, search, `PATCH`, `PUT`, `DELETE`), and serves interactive Swagger UI at `/docs`. + +## License -- **Runtime**: Node.js -- **Framework**: Fastify -- **Architecture**: TypeScript -- **Database**: PostgreSQL and SQLite -- **Cache**: In-memory, Redis, and Memcached -- **Validation**: AJV -- **Documentation**: Swagger / OpenAPI -- **Testing**: Vitest +ROSS is open-source software licensed under the **MIT License** (`Copyright (c) 2026 Abhishek Chatterjee`). See the [LICENSE](https://github.com/imdeepmind/rocket/blob/develop/ross/LICENSE) file in the [imdeepmind/rocket](https://github.com/imdeepmind/rocket) repository for full terms. diff --git a/ross/docs/docs/programmatic.md b/ross/docs/docs/programmatic.md index 805c06cb..3d1614c0 100644 --- a/ross/docs/docs/programmatic.md +++ b/ross/docs/docs/programmatic.md @@ -35,7 +35,14 @@ const {app, routes} = await createServer(config); await app.listen({port: 3000, host: '0.0.0.0'}); ``` -`createServer()` runs the full configuration pipeline — environment variable resolution, defaults, normalization, and schema validation — and returns: +`createServer()` runs the full configuration pipeline: + +- Environment variable resolution +- Defaults +- Normalization +- Schema validation + +It returns: | Property | Description | | --- | --- | @@ -54,21 +61,10 @@ import type {AppConfigInput} from '@imdeepmind/ross'; export const config: AppConfigInput = { application: { name: 'Task API', - logLevel: 'info', - }, - infrastructure: { - database: { - engine: 'sqlite', - connection: {url: './database.db'}, - }, - cache: { - engine: 'memory', - }, }, data: { models: { tasks: { - timestamps: true, fields: { id: {type: 'integer', primaryKey: true, autoIncrement: true}, title: {type: 'string', nullable: false}, @@ -180,7 +176,7 @@ const {app} = await createServer(config); const response = await app.inject({ method: 'GET', - url: '/api/tasks', + url: '/api/v1/tasks', }); console.log(response.statusCode, response.json()); @@ -214,7 +210,12 @@ request.authenticate(); | `defineConfig(config, options?)` | function | Runs the configuration pipeline and returns a `ResolvedAppConfig`. | | `migrateDatabase(config)` | function | Applies database schema and custom migrations from a resolved configuration. | -Useful exported types include `AppConfigInput`, `ResolvedAppConfig`, `CreateServerOptions`, `StartServerResult`, `RouteInfo`, `FastifyInstance`, and `FastifyRequest`. +Useful exported types include: + +- **Server & Config**: `AppConfigInput`, `ResolvedAppConfig`, `CreateServerOptions`, `DefineConfigOptions`, `StartServerResult`, `RouteInfo`, `Mode`, `HTTPMethod`, `StructuredResponse` +- **Config Sections**: `ApisConfig`, `AuthProvider`, `CacheDbConfig`, `CustomEndpointConfig`, `DatabaseConfig`, `EmailConfig`, `ModelConfigInput`, `ModelFieldConfig`, `WebhookConfig` +- **Integrations & Handlers**: `ICache`, `DatabaseQuery`, `TransactionClient`, `EmailSender`, `CustomFunctionHandler`, `IOtpService` +- **Fastify**: `FastifyInstance`, `FastifyRequest` ## Comparison with the CLI From 46227fcb7afbc11571fe899ab50ae633d61a7445 Mon Sep 17 00:00:00 2001 From: Abhishek Chatterjee Date: Wed, 25 Nov 2026 20:47:33 +0530 Subject: [PATCH 2/2] chore(ross): #255: align README with updated intro documentation --- ross/README.md | 294 +++++-------------------------------------------- 1 file changed, 25 insertions(+), 269 deletions(-) diff --git a/ross/README.md b/ross/README.md index 6bc71628..9edbd970 100644 --- a/ross/README.md +++ b/ross/README.md @@ -1,59 +1,39 @@ -# Rocket OSS +# ROSS

- Rocket API Framework Logo + ROSS API Framework Logo

-Rocket is a configuration-driven API framework designed to accelerate backend development by automating standard engineering tasks. By defining models in a structured JSON format, Rocket automatically handles database schema generation, RESTful routing, authentication, request validation, and interactive documentation. +ROSS is an open-source, configuration-driven REST API framework based on Fastify. Instead of writing repetitive boilerplate for models, routes, validation, and docs, you declare your application in a single structured configuration and ROSS handles database schema management, CRUD/search/aggregate endpoints, request validation, authentication, RBAC, caching, outbound webhooks, and interactive OpenAPI/Swagger documentation automatically. -## Features +## Two Ways to Use ROSS -- **Automated API Generation**: Instant creation of CRUD, Search, Index, and Aggregate endpoints from JSON configurations. -- **Database Schema Management**: Automatic handling of table creation, relations, multi-column indexes, and foreign key constraints. -- **Multi-Engine Database Support**: Native support for PostgreSQL and SQLite. -- **Built-in Authentication**: JWT-based authentication with registration, login, password reset, and optional MFA. -- **Caching Layer**: Redis integration for high-performance caching. -- **Rate Limiting**: Configurable request rate limiting with cache-backed storage. -- **Webhooks**: Per-API webhook triggers for request/response events. -- **Custom Endpoints**: SQL-based custom endpoints with parameterized queries. -- **Interactive Documentation**: Integrated Swagger/OpenAPI UI. -- **Robust Validation**: AJV-powered JSON Schema validation for all requests. -- **Advanced Querying**: Filtering, sorting, aggregations, and full-text search. +You can run ROSS as a standalone CLI over a JSON file or use it programmatically in your Node.js/TypeScript code. -## Quick Start +### CLI (`ross`) -### 1. Installation +Point the CLI at a `ross.json` configuration file and let ROSS manage the full server lifecycle—no application code required. -Install ROSS in your project from GitHub: +- **Zero boilerplate**: Define models, auth, caching, and custom SQL/function endpoints in JSON and boot immediately with `ross dev` or `ross start`. +- **Built-in tooling**: Validate configs (`ross config validate`), inspect resolved defaults with secrets redacted (`ross config show`), and run schema/custom migrations (`ross migrate`). +- **Best for**: Rapid prototyping, standard CRUD/data APIs, and teams that want a declarative backend without maintaining server glue code. -```bash -npm install github:imdeepmind/rocket#ross-release -``` - -Or clone the repository to run from source: - -```bash -git clone https://github.com/imdeepmind/rocket.git -cd rocket/ross -npm install -``` +See the [Getting Started](docs/docs/get-started.md) guide and [CLI Reference](docs/docs/cli.md). -### 2. Initialize the Server +### Programmatic (`@imdeepmind/ross`) -Start the server using an existing configuration file: +Import `createServer`, `defineConfig`, and `migrateDatabase` directly into your Node.js or TypeScript codebase while keeping full control of the Fastify instance. -```bash -npm run dev -- dev -c example_config.json -``` +- **Type-safe configuration**: Author configs in TypeScript using `AppConfigInput` and split large setups across multiple modules. +- **Full Fastify control**: Attach custom hooks, plugins, or routes, and decide when to call `app.listen()` and `app.close()`. +- **Test-friendly**: Exercise routes in-process with `app.inject()` without binding a network port. +- **Best for**: Existing Fastify services, custom middleware/business logic, and TypeScript-first projects. -### 3. API Exploration +See [Programmatic Usage](docs/docs/programmatic.md). -Once the server is initialized, refer to the Swagger UI for interactive API documentation: -[http://localhost:3000/api/docs](http://localhost:3000/api/docs) +## Barebone Example -## 01 Barebone Configuration - -The smallest config that boots a working API is "name + one model": +The smallest configuration that boots a working API needs only `application.name` and `data.models`: ```json { @@ -72,238 +52,14 @@ The smallest config that boots a working API is "name + one model": } ``` -Run it: - -```bash -npm run dev -- dev -c examples/01-barebone/barebone_config.json -``` - -That single model gives you, on a local SQLite database: - -- `POST /api/v1/notes/` -- `GET /api/v1/notes/` -- `GET /api/v1/notes/id/:id` -- `GET /api/v1/notes/search/title?title_search=...` -- `PATCH /api/v1/notes/title/:title` -- `PUT /api/v1/notes/title/:title` -- `PATCH /api/v1/notes/status/:status` -- `DELETE /api/v1/notes/status/:status` -- Swagger UI at `/docs` (dev mode) - -Inspect the fully resolved config (with secrets redacted): - -```bash -npm run dev -- config show -c examples/01-barebone/barebone_config.json -``` - -## Configuration - -Rocket uses a `config.json` file for system orchestration. Below is a minimal configuration example: - -```json -{ - "application": { - "name": "Rocket OSS", - "logLevel": "info", - "rateLimit": { - "enabled": true, - "max": 1000, - "timeWindow": "15m" - } - }, - "docs": { - "openapi": { - "enabled": true, - "path": "/api/docs", - "info": { - "title": "Rocket API", - "version": "1.0.0" - } - } - }, - "infrastructure": { - "database": { - "engine": "sqlite", - "connection": { "url": "./database.db" } - }, - "cache": { - "engine": "redis", - "connection": { "url": "redis://localhost:6379" } - } - }, - "authentication": { - "enabled": true, - "provider": { - "type": "up-auth", - "config": { - "userModel": { - "model": "users", - "idField": "id", - "usernameField": "email", - "passwordField": "password" - }, - "jwtSecret": "your-secret-key", - "mfaRequired": false - } - } - }, - "data": { - "models": { - "users": { - "timestamps": true, - "fields": { - "id": { - "type": "integer", - "primaryKey": true, - "autoIncrement": true, - "apis": ["index", "edit", "delete"] - }, - "email": { - "type": "string", - "unique": true, - "nullable": false, - "apis": ["search", "index"], - "query": ["eq", "sort"] - }, - "name": { - "type": "string", - "nullable": true, - "query": ["sort"] - } - } - } - } - } -} -``` - -### Defaults and resolved configuration - -Only two things are strictly required in a config file: - -- `application.name` -- `data.models` (each model needs `fields`, each field needs `type`) - -Everything else is resolved by a single defaults layer before validation and -before the server starts. Unknown values still fail validation; omitted values -are filled in. - -| Section | Default | -|---|---| -| `application.logLevel` | `info` | -| `application.rateLimit` | `{ enabled: false, max: 100, timeWindow: "1m", rateLimitHealthAPI: false }` | -| `application.dangerouslyOverrideDefaultVariant` | `v1` | -| `docs.openapi` | enabled in `dev`, disabled in `prod`; path `/docs`; version `1.0.0`; info title falls back to `application.name` | -| `infrastructure.database` | dev: SQLite at `./database.db`; **prod: required** | -| `infrastructure.cache` | `{ engine: "memory" }`; Redis requires `connection.url` | -| database / cache timeout | `10000` ms | -| `authentication` | disabled (`{ enabled: false }`) | -| up-auth `tokenExpiration` | `1d` | -| up-auth `mfaRequired` | `false` | -| `apis`, `customEndpoints`, `apiVariants`, `integrations` | empty | - -#### Inspecting the resolved config - -`config show` runs the full pipeline (env resolution → defaults → -validation), prints the resolved JSON, and exits without starting the server: +Start the development server: ```bash -npm run dev -- config show -c config.json +ross dev -c ross.json ``` -Secrets are redacted in the output: `jwtSecret`, API keys, and credentials -embedded in database/cache URLs (`postgresql://user:pass@host/db` prints as -`postgresql://***:***@host/db`). An invalid config prints the validation error -and exits with code 1. - -### Field Configuration - -Each field supports granular control over API capabilities: - -**APIs** - Controls which endpoints expose the field: -- `search`: Full-text search endpoint -- `index`: Get by primary key endpoint -- `edit`: Update endpoint -- `delete`: Delete endpoint - -**Query Operations** - Filtering and sorting capabilities: -- `eq`, `ne`: Equality/inequality filters -- `lt`, `lte`, `gt`, `gte`: Comparison filters -- `in`, `not_in`: Array membership filters -- `sort`: Enable sorting by this field - -**Aggregations** - Data aggregation functions: -- `count`, `avg`, `sum`, `min`, `max`, `frequency` - -### Advanced Features - -**Relations**: Define foreign key relationships between models with cascade actions (`belongsTo`). - -**Custom Endpoints**: Execute parameterized SQL queries via custom HTTP endpoints. - -**Webhooks**: Configure per-API webhooks that trigger on request/response with customizable payloads. - -**Server-Side Parameters**: Inject server-controlled parameters into API requests for enhanced security. - -See `example_config.json` for a complete configuration reference. - -## API Reference - -Rocket generates standardized endpoints for every configured model. - -### Model Endpoints - -| Method | Endpoint | Description | -| :--- | :--- | :--- | -| `POST` | `/:model` | Creates a new record. | -| `GET` | `/:model` | Retrieves records with pagination and filtering support. | -| `GET` | `/:model/:id` | Retrieves a specific record by primary key. | -| `PATCH` | `/:model/:id` | Performs partial updates on a specific record. | -| `DELETE` | `/:model/:id` | Deletes a specific record. | -| `POST` | `/:model/search` | Executes advanced search queries. | -| `POST` | `/:model/aggregate` | Performs data aggregations (count, sum, avg, etc.). | - -### Authentication Endpoints (when `up-auth` is enabled) - -| Method | Endpoint | Description | -| :--- | :--- | :--- | -| `POST` | `/auth/register` | Register a new user account. | -| `POST` | `/auth/login` | Authenticate and receive JWT token. | -| `POST` | `/auth/change-password` | Change password for authenticated user. | -| `POST` | `/auth/forgot-password` | Initiate password reset flow. | -| `POST` | `/auth/otp/verify/login` | Verify OTP for login (when MFA enabled). | -| `POST` | `/auth/otp/verify/register` | Verify OTP for registration. | -| `POST` | `/auth/otp/verify/forgot-password` | Verify OTP for password reset. | - -## Development and Testing - -### Testing - -Testing is managed via Vitest to ensure performance and reliability. - -```bash -# Execute the test suite -npm test - -# Generate coverage data -npm run coverage -``` - -### Code Quality - -Linting is enforced to maintain high code standards: - -```bash -npm run lint:check -``` +With that single model, ROSS sets up a local SQLite database (`./database.db`), mounts REST endpoints under `/api/v1/notes` (`POST`, `GET`, search, `PATCH`, `PUT`, `DELETE`), and serves interactive Swagger UI at `/docs`. -## Technology Stack +## License -- **Runtime**: Node.js -- **Framework**: Fastify -- **Architecture**: TypeScript -- **Database**: PostgreSQL and SQLite -- **Cache**: Redis -- **Validation**: AJV -- **Documentation**: Swagger / OpenAPI -- **Testing**: Vitest +ROSS is open-source software licensed under the **MIT License** (`Copyright (c) 2026 Abhishek Chatterjee`). See [LICENSE](LICENSE) for full terms.