feat: initialize ingest-api with Koa and telemetry handling
- Create ingest-api with Koa framework for handling device telemetry. - Implement telemetry ingestion with MongoDB, Redis, and PostgreSQL. - Add API endpoints for telemetry and health checks. - Set up testing with Vitest for unit and end-to-end tests. - Configure Prettier and ESLint for code formatting and linting. - Create Docker Compose setup for PostgreSQL, MongoDB, and Redis services. - Establish contracts package for shared Zod schemas and TypeScript types. - Implement React frontend with device status and greeting functionalities. - Add VS Code setup documentation for onboarding developers.
This commit is contained in:
1 parent
534fa6dc51
commit
7923ba1b8d
70 files changed
+3085
-3434
No files matched your search
@@ -1,20 +1,18 @@
|
||||
# From Express + SQL to Monorepo with Nest Fastify, Vite React, and trest
|
||||
# From Express + SQL to Monorepo with Koa, Vite React, and trest
|
||||
|
||||
This guide is for developers who already know Express APIs and SQL, and are new to Yarn workspaces, NestJS, and private package usage.
|
||||
This guide is for developers who already know Express APIs and SQL, and are new to Yarn workspaces, Koa, and private package usage.
|
||||
|
||||
## 1) What You Are Building
|
||||
|
||||
Target architecture:
|
||||
|
||||
- Backend API: NestJS on Fastify
|
||||
- Backend API: Koa + trest
|
||||
- Frontend: Vite + React + Ant Design
|
||||
- Shared/private integration: trest in an isolated adapter package
|
||||
- Monorepo manager: Yarn workspaces
|
||||
|
||||
Why this shape:
|
||||
|
||||
- Keep your main backend on a scalable Fastify stack.
|
||||
- Evaluate trest without coupling everything to Koa ecosystem packages.
|
||||
- Keep the HTTP API on Koa so it matches trest's router.
|
||||
- Keep one repo and one lockfile for easier onboarding.
|
||||
|
||||
## 2) Mental Map (Old to New)
|
||||
@@ -159,32 +157,22 @@ Checkpoint:
|
||||
|
||||
- Vite app runs and Ant Design components render.
|
||||
|
||||
### Step F: Introduce trest Safely
|
||||
### Step F: Introduce trest on the API
|
||||
|
||||
Recommended approach:
|
||||
|
||||
- Keep trest usage in a dedicated package, for example packages/trest-adapter.
|
||||
- Expose only framework-agnostic functions from that adapter.
|
||||
- Avoid leaking Koa-specific types into app-wide contracts.
|
||||
|
||||
Starter commands:
|
||||
Install trest and its Koa peers in `apps/api`:
|
||||
|
||||
```bash
|
||||
mkdir -p packages/trest-adapter
|
||||
cd packages/trest-adapter
|
||||
yarn init -y
|
||||
yarn add @jig-software/trest koa @koa/router koa-body path-to-regexp zod bson
|
||||
yarn workspace api add @jig-software/trest koa @koa/router koa-body path-to-regexp zod bson
|
||||
```
|
||||
|
||||
Checkpoint:
|
||||
|
||||
- Importing trest from adapter works.
|
||||
- `GET /greeting?name=Marco` returns a JSON greeting from the Koa app.
|
||||
|
||||
### Step G: Wire API and Web
|
||||
|
||||
- Add one simple API endpoint in Nest.
|
||||
- Call endpoint from React page.
|
||||
- Render response using an Ant Design component.
|
||||
- Call `/greeting` from a React page.
|
||||
- Render the response using an Ant Design component.
|
||||
|
||||
Checkpoint:
|
||||
|
||||
@@ -197,8 +185,6 @@ marco-trest-test/
|
||||
apps/
|
||||
api/
|
||||
web/
|
||||
packages/
|
||||
trest-adapter/
|
||||
docs/
|
||||
package.json
|
||||
yarn.lock
|
||||
@@ -209,11 +195,10 @@ marco-trest-test/
|
||||
|
||||
Use these rules to avoid confusion:
|
||||
|
||||
1. Put backend runtime dependencies in apps/api.
|
||||
1. Put Koa, trest, and other backend runtime dependencies in apps/api.
|
||||
2. Put frontend runtime dependencies in apps/web.
|
||||
3. Put trest boundary dependencies in packages/trest-adapter.
|
||||
4. Keep root dependencies minimal and mostly tooling.
|
||||
5. Run installs from root unless targeting one workspace intentionally.
|
||||
3. Keep root dependencies minimal and mostly tooling.
|
||||
4. Run installs from root unless targeting one workspace intentionally.
|
||||
|
||||
## 8) Troubleshooting You Are Likely to Hit
|
||||
|
||||
|
||||
Reference in new issue
Block a user