Przejdź do treści
Biblioteka skilli
Programowanie · Budowanie i kod

building-api-modules

/building-api-modules

Dodaje lub zmienia moduł API Elysia 2 i Effect v4 według podziału na kontroler, serwis, błąd i mapper.

Repozytorium
ai-interview ↗
Licencja
MIT
Ostatnia zmiana repozytorium
29.10.2026

Ocena i bezpieczeństwo

100/ 100Klasa: dobry
Format25 / 25
Frontmatter z nazwą i opisem, poprawna nazwa, opis do 1024 znaków, nazwa zgodna z folderem.
Odkrywalność25 / 25
Opis mówi, kiedy użyć skilla, ma sensowną długość i jest w 3. osobie.
Treść35 / 35
Co najmniej 150 słów i do 500 linii, nagłówki, listy kroków, przykłady albo kod.
Higiena15 / 15
Bez zaślepek typu TODO, bez ścieżek Windows, z licencją.
Ryzykobrak sygnałów w skanie
Pliki w paczce
1
Skrypty
0
Komentarze HTML
0
Adresy URL w SKILL.md
0
Przestarzałość

Brak sygnałów. Repozytorium zmienione 29.10.2026, bez odwołań do wycofanych modeli i API.

Licencja

MIT, otwarta: można używać i zmieniać, z zachowaniem informacji o autorze.

Co robi i kiedy

Dodaje lub zmienia moduł API Elysia 2 i Effect v4 według podziału na kontroler, serwis, błąd i mapper.

Oryginalny opis (EN)

Adds or changes an Elysia 2 + Effect v4 API module following the controller/service/error/mapper split, the ok/fail response envelope, and the Effect-at-the-boundary rules. Use when creating or editing a domain module under apps/api.

Jak działa

  1. Module layout
  2. Steps for a new module
  3. Rules that are easy to miss
Sekcje z nagłówków SKILL.md, w oryginale · 52 linii, 294 słów
Podgląd SKILL.md
---
name: building-api-modules
description: Adds or changes an Elysia 2 + Effect v4 API module following the controller/service/error/mapper split, the ok/fail response envelope, and the Effect-at-the-boundary rules. Use when creating or editing a domain module under apps/api.
---

# Building API modules

Elysia 2 (Kiana) + Effect v4 backend. Read `apps/api/AGENTS.md` first — it is the
authoritative rule set. This skill is the step-by-step path.

## Module layout

One directory per domain under `apps/api/src/modules/<name>/`:

```text
modules/<name>/
├── index.ts     Elysia controller — HTTP only, thin
├── service.ts   business logic (Effect service when it has deps/errors)
├── error.ts     domain errors (Schema.TaggedError)
├── mapper.ts    database row → shared wire type
```

Reference implementations: `modules/session/progression.ts` (pure logic, plain
function) and `modules/interview` (real dependency + typed error, full Effect
service).

## Steps for a new module

1. Add the request/response schemas to `packages/shared/src/schemas/` as Effect
   `Schema.Struct` (wire timestamps are ISO strings). Re-export from the index.
2. Write `service.ts`:
   - **Pure logic** → a plain function (`modules/session/progression.ts`). Do NOT
     wrap it in `Context.Service`/`Layer`/`ManagedRuntime`.
   - **Real effect** (async, typed error, resource, dependency) → `Context.Service`
     - `Layer` + `Schema.TaggedError` (`modules/interview/service.ts` + `error.ts`).
3. Write `error.ts` for domain failures with `Schema.TaggedError`.
4. Write `mapper.ts` mapping the Drizzle `$inferSelect` row to the shared wire type.
5. Write `index.ts`: a thin Elysia controller. Return `ok(...)`, declare `response`
   with `Schema.toStandardSchemaV1(ApiSuccessSchema(...))` and OpenAPI `detail`.
   Run effects at the boundary: `runtime.runPromise` (async) or `runtime.runSync`
   (sync) from `src/runtime.ts`, via `Service.use((s) => s.method(...))`.
6. If the module has a service layer, add it to the single runtime in
   `src/runtime.ts` (`ManagedRuntime.make(Layer.mergeAll(...))`).
7. If it has new errors, map them in `plugins/logger.ts` `resolveErrorDefinition`
   (by `_tag`/`code`) to the envelope.

## Rules that are easy to miss

- Every response is `{ ok: true, data }` or `{ ok: false, error, requestId }`.
  Never return a bare payload.
- `yield*` inside Effect, `await` only at the controller boundary.
- `Layer.succeed` for stateless services, `Layer.effect` for stateful/dependent,
  `Effect.acquireRelease` for resources.
- Never leak internal error details; `resolveErrorDefinition` maps everything to a
  stable code/message.

Wersje

W bazie nie ma innych skilli o nazwie building-api-modules.

Migawka bazy z 13.11.2026 · wersja paczki 82bfcb5cd522 (skrót SHA-256 całej paczki)

Pobrania w ostatnich 30 dniach: 0 · ranking

Zgłoś problem z tym skillem: szkodliwa treść, błędny opis albo prośba autora o usunięcie.

Podobne skille

  • 86add-resource
    Dodaje zasób REST do API NestJS od początku do końca: moduł, kontroler, serwis, DTO i testy kontraktowe.
  • 91effect-development
    Podpowiada, jak pisać i przeglądać kod składający się z API i wzorców Effect.
  • 100elysiajs
    Buduje, debuguje i migruje backendy TypeScript w Elysia v2 z walidacją, wtyczkami, typowanymi klientami i wdrożeniem.
  • 95effect-service-design
    Projektuje usługi w Effect i ocenia istniejący kod pod kątem usług, warstw i kompozycji.
  • 100java-crud-module
    Tworzy szkielet nowego modułu biznesowego CRUD w warstwowym projekcie Spring Boot i MyBatis-Plus w pełnym przepływie dziewięciu plików: migracja, encja, mapper, DTO, konwerter, serwis, facade i kontroler.
  • 100effect-v3-to-v4
    Prowadzi migrację kodu z Effect v3 do Effect v4, w tym aktualizację pakietów effect i @effect/* w obrębie tej granicy wersji.

Uwagi i zgłoszenia

Wiadomość trafi do Bartosza Sokolińskiego. Adres e-mail jest potrzebny tylko do odpowiedzi. Szczegóły w polityce prywatności.