|
| 1 | +# ri-shared — code shared across the RedisInsight apps (API + UI) |
| 2 | + |
| 3 | +Modules here are consumed by **both** the API (relative imports, e.g. |
| 4 | +`src/ri-shared/utils/array-index`) and the UI (the `riShared/*` path alias). They live |
| 5 | +inside `api/src` because the api's production build (`nest build` → `node dist/src/main`) |
| 6 | +compiles with `api/src` as the tsc rootDir — sources outside it restructure `dist/` and |
| 7 | +break the packaged app. The UI/Storybook/jest aliases simply point into this folder, so |
| 8 | +shared code ships with zero extra packaging surface (desktop bundles it like any api file). |
| 9 | + |
| 10 | +## What belongs here |
| 11 | + |
| 12 | +- Cross-boundary **contracts**: value formats both sides must agree on (e.g. the |
| 13 | + BigInt-as-string array index format), stable message formats, shared constants. |
| 14 | +- Small **dependency-free** utilities needed verbatim on both sides. |
| 15 | + |
| 16 | +## Rules |
| 17 | + |
| 18 | +- **No imports** from Nest, React, ioredis, lodash or anything else — dependency-free |
| 19 | + TypeScript only (the UI and API have separate node_modules; nothing here may assume |
| 20 | + either). |
| 21 | +- **es2019-compatible**: the api compiles this folder with `target: es2019` — no BigInt |
| 22 | + literals (`1n` is TS2737; use `BigInt('...')`), no newer syntax. |
| 23 | +- API code style (semicolons) — this folder is linted by `yarn lint:api`. |
| 24 | +- Tests live next to the module (`*.spec.ts`, runs under the api jest config) and define |
| 25 | + the shared behavior once — UI consumers exercise it through their barrel imports. |
| 26 | + |
| 27 | +## Alias wiring (when adding the alias to a new consumer) |
| 28 | + |
| 29 | +`redisinsight/ui/tsconfig.json` + `redisinsight/ui/vite.config.mjs` + |
| 30 | +`jest.config.cjs` (root, UI tests) + `.storybook/vite.config.ts` + |
| 31 | +`redisinsight/desktop/tsconfig.json` all map `riShared/*` → |
| 32 | +`redisinsight/api/src/ri-shared/*`. |
0 commit comments