Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .github/workflows/rocket-platform.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,14 @@ name: Rocket Platform
on:
push:
branches: [main, develop]
paths:
- 'rocket/platform/**'
- '.github/workflows/rocket-platform.yml'
pull_request:
branches: [main, develop]
paths:
- 'rocket/platform/**'
- '.github/workflows/rocket-platform.yml'

jobs:
lint:
Expand Down
6 changes: 6 additions & 0 deletions .github/workflows/ross-docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,14 @@ name: ROSS Docs
on:
push:
branches: [main, develop]
paths:
- 'ross/docs/**'
- '.github/workflows/ross-docs.yml'
pull_request:
branches: [main, develop]
paths:
- 'ross/docs/**'
- '.github/workflows/ross-docs.yml'

jobs:
lint:
Expand Down
8 changes: 8 additions & 0 deletions .github/workflows/ross.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,16 @@ name: ROSS
on:
push:
branches: [main, develop]
paths:
- 'ross/**'
- '!ross/docs/**'
- '.github/workflows/ross.yml'
pull_request:
branches: [main, develop]
paths:
- 'ross/**'
- '!ross/docs/**'
- '.github/workflows/ross.yml'

jobs:
lint:
Expand Down
7 changes: 0 additions & 7 deletions .husky/commit-msg

This file was deleted.

16 changes: 0 additions & 16 deletions .husky/pre-commit

This file was deleted.

86 changes: 31 additions & 55 deletions AGENTS.md
Original file line number Diff line number Diff line change
@@ -1,79 +1,55 @@
# AGENTS.md — Rocket Monorepo

Repository containing two independent software projects:
- **ROSS (`ross/`)**: Config-driven REST API framework (open-source, MIT). TypeScript, Fastify 5, PostgreSQL/SQLite, Vitest 4.
- **Rocket (`rocket/`)**: Source-available backend deployment, hosting, and management platform (PolyForm Shield 1.0.0).
Monorepo containing ROSS and the Rocket platform.

## Commands
## Repository Structure

Commands can be run from the repository root via `./dev.sh` (which delegates to `ross/dev.sh`) or directly within `ross/`:
- **`ross/`**: ROSS — open-source, configuration-driven REST API framework (MIT). TypeScript, Fastify 5, Drizzle, Vitest.
- **`ross/docs/`**: ROSS documentation site built with Docusaurus (separate `package.json`, markdown lint, and CI workflow).
- **`rocket/platform/`**: Rocket Platform — source-available backend deployment, hosting, and management web app (PolyForm Shield 1.0.0). Next.js, TypeScript, Tailwind CSS, Storybook.
- **`.github/workflows/`**: CI workflows scoped per package (`ross.yml`, `ross-docs.yml`, `rocket-platform.yml`) plus repo-wide `commit-lint.yml`.

| Command | Action |
| --- | --- |
| `./dev.sh dev` | Run dev server with `--config example_config.json` |
| `./dev.sh coverage` | Full test suite with coverage |
| `./dev.sh test` | Run tests |
| `./dev.sh check` | Compile + coverage + lint:write |
| `./dev.sh db` | Start redis and db Docker containers |
| `./dev.sh csserve` | Serve coverage report via HTTP |
## Commands (`./dev.sh`)

Commits automatically run pre-commit hooks, so there is no need to manually run tests or `./dev.sh check` before committing.
Run project commands from the repository root via `./dev.sh <project> <operation>` (each project also has its own `dev.sh`):

## Testing

- DB is always mocked: `tests/setup.ts` globally mocks `pg` and `better-sqlite3`.
- Route tests use `createTestApp()` from `tests/helpers/test-app.ts` with real Fastify + `fastify.inject()`.
- Plugin tests create throw-away Fastify instances per test.
- Mock state is on shared `pgQueryMock`, `sqliteAllMock` etc. from `tests/helpers/db-mocks.ts`.

## Path aliases

- `@/` → `src/`
- `@tests/` → `tests/`
- Compiled JS needs `tsc-alias` to resolve these (part of `compile`).
```bash
./dev.sh ross <operation> # dev, test, coverage, check, e2e, db, csserve, release
./dev.sh ross-docs <operation> # dev, build, serve, typecheck, lint, check, clear
./dev.sh rocket-platform <operation> # dev, build, start, lint, lint:fix, check, storybook, build-storybook
```

## Import order (enforced by Prettier)
Run `./dev.sh <project>` with no operation to see its full usage.

Builtins → Third-party → `@/migrator` → `@/plugin` → `@/server` → `@/lib` → `@/routes` → `@/interfaces` → `@/types` → `@/validators` → `@/utils` → `@/constants` → `@tests/` → relative `./`
## Commit Messages

## Commit messages
Enforced in CI by `commitlint` (`commitlint.config.cjs`). Local Git hooks (Husky) are not used.

```
type(scope): #<NUMBER>: message
```

Types: `feat`, `chore`, `ci`, `bug`, `refactor`, `test`. Max header: 120 chars.
- **Types**: `feat`, `chore`, `ci`, `bug`, `refactor`, `test`
- **Scopes**: `ross`, `ross-docs`, `rocket-platform`, `rocket`, `repo` (`repo` for global/monorepo changes or changes spanning multiple packages; others for project-scoped changes)
- **Max header length**: 120 characters

Example: `feat(auth): #123: add token refresh`
Example: `feat(ross): #123: add token refresh`

## Branch naming
## Branch Naming & Flow

```
<type>/#<issue-number>-<short-description>
```

- `<type>` is one of the allowed commit types: `feat`, `chore`, `ci`, `bug`, `refactor`, `test`.
- `<issue-number>` is the GitHub issue being worked on.
- `<short-description>` is lowercase, hyphen-separated.

Examples: `feat/#86-migrate-commit-msg`, `bug/#92-fix-auth-refresh`, `refactor/#74-split-where-builder`

Flow:

1. Create a branch from the default branch: `git switch -c feat/#86-migrate-commit-msg`.
2. Wait for the developer to review and test your changes.
3. Commit using the commit convention: `git commit -m "chore(ci): #86: migrate commit convention from JIRA to GitHub Issues"`.
4. Push the branch (quote `#` in shell commands): `git push -u origin 'feat/#86-migrate-commit-msg'`.
5. Open a PR that references the issue.
- `<type>`: one of `feat`, `chore`, `ci`, `bug`, `refactor`, `test`
- `<issue-number>`: GitHub issue number
- `<short-description>`: lowercase, hyphen-separated

## Architecture essentials
Examples: `feat/#86-migrate-commit-msg`, `chore/#221-monorepo-ci-and-tooling`

- **Entrypoint:** `src/main.ts` (commander CLI) → `startServer()` in `src/server.ts`.
- **Fastify custom decorators** (augmented in `src/types/fastify.d.ts`): `app.db`, `app.buildResponse()`, `app.appConfig`, `app.cache`, `app.callWebhook`, `app.enforceSSP`.
- **DB abstraction:** Uniform `DatabaseQuery` interface (`{changes, rows}`). PG uses `pg.Pool`, SQLite uses `better-sqlite3` (sync wrapped in Promise). DDL queries are blocked.
- **Config env vars:** Use `env:VARNAME` in JSON config values — resolved by `src/lib/config/env.ts`.
- **Config validation:** AJV schema in `src/validators/config/schema.ts`. Reference config: `example_config.json`.
- **Plugin registration order** in `startServer()`: db → cache → communicate → rate-limit → response → ssp → webhook → auth. Fastify-plugin (`fp`) wrapper used throughout.
- **Shared library code lives in `src/lib/`**, grouped by framework layer: `config/` (env resolution, API identifiers, `config.apis` accessors), `schema/` (JSON Schema builders for Swagger), `sql/` (WHERE-clause filters, placeholder parsing), `server/` (prevalidation, welcome screen). Tests mirror this under `tests/lib/`.
- **ESM only** (`"type": "module"`). No require().
- **`docs/`** is a separate Docusaurus site (own package.json) — not part of the main project.
1. Create a branch from `develop`: `git switch -c feat/#123-short-description`
2. Make changes and verify with the relevant `./dev.sh <project> check`
3. Wait for the developer to review and test the changes — **commit only when explicitly asked to commit**
4. Commit using the commit convention: `git commit -m "feat(ross): #123: short description"`
5. Push the branch (quote `#` in shell): `git push -u origin 'feat/#123-short-description'`
6. Open a PR referencing the issue.
6 changes: 4 additions & 2 deletions commitlint.config.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ module.exports = {
extends: [require.resolve('@commitlint/config-conventional', { paths: [__dirname + '/ross'] })],
rules: {
'type-enum': [2, 'always', ['feat', 'chore', 'ci', 'bug', 'refactor', 'test']],
'scope-enum': [2, 'always', ['ross', 'ross-docs', 'rocket-platform', 'rocket', 'repo']],
'scope-empty': [2, 'never'],
'header-max-length': [2, 'always', 120],
'subject-empty': [2, 'never'],
'type-case': [2, 'always', 'lower-case'],
Expand All @@ -14,10 +16,10 @@ module.exports = {
rules: {
'header-match-issue': ({ header }) => {
// type(scope): #<NUMBER>: message
const regex = /^(feat|chore|ci|bug|refactor|test)\([a-z0-9-]+\): #\d+: .+/;
const regex = /^(feat|chore|ci|bug|refactor|test)\((ross|ross-docs|rocket-platform|rocket|repo)\): #\d+: .+/;
return [
regex.test(header),
`Commit message must follow the convention: type(scope): #<NUMBER>: message (e.g. feat(auth): #123: add token refresh)\nNumber refers to the GitHub issue.\nTypes: feat, chore, ci, bug, refactor, test`,
`Commit message must follow the convention: type(scope): #<NUMBER>: message (e.g. feat(ross): #123: add token refresh)\nNumber refers to the GitHub issue.\nTypes: feat, chore, ci, bug, refactor, test\nScopes: ross, ross-docs, rocket-platform, rocket, repo`,
];
},
},
Expand Down
32 changes: 31 additions & 1 deletion dev.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,35 @@
#!/usr/bin/env bash
set -euo pipefail

exec bash ross/dev.sh "$@"
ROOT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"

PROJECT="${1:-}"
if [[ -z "$PROJECT" ]]; then
echo "Usage: ./dev.sh <project> <operation> [args...]"
echo ""
echo "Projects:"
echo " ross ROSS API framework (ross/)"
echo " ross-docs ROSS documentation site (ross/docs/)"
echo " rocket-platform Rocket platform web app (rocket/platform/)"
exit 1
fi

shift

case "$PROJECT" in
ross)
exec bash "$ROOT_DIR/ross/dev.sh" "$@"
;;
ross-docs)
exec bash "$ROOT_DIR/ross/docs/dev.sh" "$@"
;;
rocket-platform)
exec bash "$ROOT_DIR/rocket/platform/dev.sh" "$@"
;;
*)
echo "Unknown project: $PROJECT"
echo ""
echo "Available projects: ross, ross-docs, rocket-platform"
exit 1
;;
esac
47 changes: 47 additions & 0 deletions rocket/platform/dev.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
#!/usr/bin/env bash
set -euo pipefail

SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
cd "$SCRIPT_DIR"

case "${1:-help}" in
dev)
npm run dev
;;
build)
npm run build
;;
start)
npm run start
;;
lint)
npm run lint && npm run prettier
;;
lint:fix)
npm run prettier:write
;;
check)
npm run lint && npm run prettier && npm run build
;;
storybook)
npm run storybook
;;
build-storybook)
npm run build-storybook
;;
*)
echo "Usage: ./dev.sh <operation>"
echo ""
echo "Operations:"
echo " dev Start Next.js dev server"
echo " build Build Next.js production bundle"
echo " start Start Next.js production server"
echo " lint Run ESLint and Prettier check"
echo " lint:fix Format files with Prettier"
echo " check Lint + Prettier check + build"
echo " storybook Start Storybook dev server"
echo " build-storybook Build Storybook static site"
exit 1
;;
esac

10 changes: 8 additions & 2 deletions ross/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,17 @@ Rocket is a configuration-driven API framework designed to accelerate backend de

### 1. Installation

Clone the repository and install dependencies:
Install ROSS in your project from GitHub:

```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
cd rocket/ross
npm install
```

Expand Down
21 changes: 21 additions & 0 deletions ross/dev.sh
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,26 @@ case "${1:-help}" in
e2e)
npm run test:e2e
;;
release)
BRANCH="${2:-ross-release}"
REMOTE_URL="$(git -C "$SCRIPT_DIR" remote get-url origin)"
npm run clean && npm run compile

TMP_DIR="$(mktemp -d)"
trap 'rm -rf "$TMP_DIR"' EXIT

mkdir -p "$TMP_DIR/build"
cp "$SCRIPT_DIR/package.json" "$TMP_DIR/"
cp "$SCRIPT_DIR/README.md" "$TMP_DIR/"
cp "$SCRIPT_DIR/LICENSE" "$TMP_DIR/"
cp -R "$SCRIPT_DIR/build/src" "$TMP_DIR/build/src"

git -C "$TMP_DIR" init -q
git -C "$TMP_DIR" add -A
git -C "$TMP_DIR" commit -q -m "chore(ross): release build"
git -C "$TMP_DIR" push -f "$REMOTE_URL" "HEAD:$BRANCH"
echo "Pushed ross build to $BRANCH ($REMOTE_URL)"
;;
*)
echo "Usage: ./dev.sh <operation>"
echo ""
Expand All @@ -37,6 +57,7 @@ case "${1:-help}" in
echo " e2e Run Playwright E2E API tests"
echo " db Start redis and db containers"
echo " csserve Serve coverage report via HTTP"
echo " release Build ross and force-push to release branch (default: ross-release)"
exit 1
;;
esac
43 changes: 43 additions & 0 deletions ross/docs/dev.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
#!/usr/bin/env bash
set -euo pipefail

SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
cd "$SCRIPT_DIR"

case "${1:-help}" in
dev)
npm run start
;;
build)
npm run build
;;
serve)
npm run serve
;;
typecheck)
npm run typecheck
;;
lint)
npm run lint:md
;;
check)
npm run lint:md && npm run typecheck && npm run build
;;
clear)
npm run clear
;;
*)
echo "Usage: ./dev.sh <operation>"
echo ""
echo "Operations:"
echo " dev Start Docusaurus dev server"
echo " build Build documentation site"
echo " serve Serve built documentation site"
echo " typecheck Run TypeScript typecheck"
echo " lint Run markdown lint"
echo " check Markdown lint + typecheck + build"
echo " clear Clear Docusaurus cache"
exit 1
;;
esac

Loading
Loading