@palbase/backend 33.0.1 → 33.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -7,7 +7,7 @@ import {
7
7
  isController,
8
8
  resolveController,
9
9
  resolveEffectiveAuth
10
- } from "../chunk-BRLJOXWS.js";
10
+ } from "../chunk-AAT5G7KY.js";
11
11
  import {
12
12
  __commonJS,
13
13
  __name,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@palbase/backend",
3
- "version": "33.0.1",
3
+ "version": "33.0.2",
4
4
  "description": "Palbase Backend SDK — class controllers (@Controller/@Get/@Post + @Body/@QueryParams/@Param), error classes, schema DSL",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -44,7 +44,7 @@ shape you find there is the shape to copy.
44
44
  | A business rule, a calculation, an ordering | the service |
45
45
  | Return an HTTP status | `throw new NotFound(…)` in the controller (or the service — no request object needed) |
46
46
  | Call another feature | name its class in your constructor — its module must `exports` it and yours must `imports` that module |
47
- | Scheduled or background work | a `@Job` class in `jobs/` — **there is no queue** |
47
+ | Scheduled or background work | a `@Job` class listed in a module's `providers` — **there is no queue** |
48
48
  | Read a setting or a secret | `Secrets.get(name)` / `Flags.isEnabled(name)` — the names are checked by the compiler |
49
49
  | Share code between controllers | a plain module they import; not a base class, not middleware |
50
50
 
@@ -86,12 +86,12 @@ wrong in this runtime:
86
86
  - **An inline return type** — `Promise<{ ok: boolean }>`, a union, or a bare
87
87
  `interface`. The deploy REFUSES it; name a zod schema.
88
88
 
89
- **A controller is exported by NAME, and no file is default-exported.** Its module
90
- imports it (`import { NotesController } from "./notes.controller"`) to
91
- list it in `controllers` — that list is the registration, and a class no list
92
- names is refused at build. (`export default` **is** required for `jobs/`,
93
- `webhooks/`, `hooks/` and `db/public.ts`, one class per file those are read off
94
- disk by name, not through a module.)
89
+ **A controller is exported by NAME, and no file is default-exported.** Its module imports
90
+ it (`import { NotesController } from "./notes.controller"`) to list it in `controllers`;
91
+ that list is the registration. `@Job`, `@Webhook`, `@Hook` and `@Room` go in the same
92
+ module's `providers`. There is no `jobs/`, `webhooks/` or `hooks/` directory and nothing
93
+ reads one a surface class no module lists is never imported, so its decorator never
94
+ runs and nothing says so. Only the schema is read by location: `db/*.ts`, one per schema.
95
95
 
96
96
  **Class and method names are your public API.** `NotesController.list` generates
97
97
  `pb.notes.list()`. Renaming either renames the call in every app; the verb and the
@@ -3,15 +3,18 @@ import { Controller, Get, z } from "@palbase/backend";
3
3
  // A route's success response IS its return type — a NAMED zod schema, read by
4
4
  // both the runtime (output validation) and the client codegen. Small projects
5
5
  // declare it beside the route; once a controller grows, move the schemas to
6
- // `models/<controller>/<endpoint>.ts` and import them.
6
+ // `dto/<endpoint>.ts` inside the same module and import them — the way
7
+ // `modules/notes/dto/create.ts` does.
7
8
  export const HealthResponse = z.object({
8
9
  status: z.string(),
9
10
  });
10
11
  export type HealthResponse = z.infer<typeof HealthResponse>;
11
12
 
12
- // A controller is a CLASS whose methods are routes. There is no module to
13
- // register it in and no export to remember: `@Controller` records the class,
14
- // and importing the file is the registration.
13
+ // A controller is a CLASS whose methods are routes, and `health.module.ts`
14
+ // beside this file is what REGISTERS it: the module imports the class by name
15
+ // and lists it in `controllers`. That list is the registration — a class no
16
+ // module names is refused at build, by name. `@Controller` describes the class;
17
+ // it does not enrol it, and neither does the folder the file sits in.
15
18
  //
16
19
  // The full path is the controller base + the method subpath, so this serves
17
20
  // `GET /health`. The generated clients call it `pb.health.check()` —
@@ -1,8 +1,9 @@
1
1
  import { z } from "@palbase/backend";
2
2
 
3
- // SCHEMAS LIVE HERE once a controller has more than a screen of them:
4
- // `models/<controller>/<endpoint>.ts`. Nothing discovers this directory it is
5
- // an ordinary import path — so the shape is yours. What is NOT optional is the
3
+ // SCHEMAS LIVE HERE once a controller has more than a screen of them: the
4
+ // module's own `dto/<endpoint>.ts`, which is where this file sits. Nothing
5
+ // discovers this directory — it is an ordinary import path — so the shape is
6
+ // yours. What is NOT optional is the
6
7
  // double export below.
7
8
  //
8
9
  // Each name is exported TWICE, under the SAME name:
@@ -4,7 +4,7 @@ import type { UserT } from "@palbase/backend";
4
4
  import { CreateNoteBody, NoteSchema } from "./dto/create";
5
5
  import { NoteService } from "./note.service";
6
6
 
7
- // The other half of the vertical that starts in `services/note.service.ts`.
7
+ // The other half of the vertical that starts in `./note.service.ts`.
8
8
  //
9
9
  // Everything a controller does here is HTTP: validate the body through a named
10
10
  // schema, name the 200 shape as the return type, turn a missing row into a
@@ -22,12 +22,14 @@ import { NoteService } from "./note.service";
22
22
  // container builds the graph once at boot.
23
23
  //
24
24
  // A class no module lists does not exist — it is refused at build, by name, and
25
- // never reaches the route table or the OpenAPI document. Being in `controllers/`
26
- // grants nothing; being in a module's list is what does.
25
+ // never reaches the route table or the OpenAPI document. WHERE the file sits
26
+ // grants nothing: the bundler walks the tree for `*.module.ts` and reads
27
+ // nothing else, so a class reached by no module is never even imported. Being
28
+ // in a module's list is what does it.
27
29
 
28
- // The schemas are in `models/notes/create.ts`. A controller with one endpoint
29
- // can keep them beside the routes; the moment there are two, they go to
30
- // `models/`, and this scaffold ships them already moved — because the shape you
30
+ // The schemas are in `./dto/create.ts`. A controller with one endpoint can keep
31
+ // them beside the routes; the moment there are two, they go to the module's
32
+ // `dto/`, and this scaffold ships them already moved — because the shape you
31
33
  // find here is the shape the next file copies.
32
34
 
33
35
  // Auth is required unless a route opts out, so `@User()` is non-null here and