@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.
- package/dist/bin/palbase-backend.cjs.map +1 -1
- package/dist/bin/palbase-backend.js +2 -2
- package/dist/{chunk-BRLJOXWS.js → chunk-AAT5G7KY.js} +2 -2
- package/dist/{chunk-BRLJOXWS.js.map → chunk-AAT5G7KY.js.map} +1 -1
- package/dist/{chunk-IKDONZ5D.js → chunk-C6COAB3E.js} +2 -2
- package/dist/engine/index.cjs.map +1 -1
- package/dist/engine/index.js +2 -2
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +1 -1
- package/dist/openapi/index.cjs +1 -1
- package/dist/openapi/index.cjs.map +1 -1
- package/dist/openapi/index.js +1 -1
- package/package.json +1 -1
- package/template/AGENTS.md +7 -7
- package/template/modules/health/health.controller.ts +7 -4
- package/template/modules/notes/dto/create.ts +4 -3
- package/template/modules/notes/notes.controller.ts +8 -6
- /package/dist/{chunk-IKDONZ5D.js.map → chunk-C6COAB3E.js.map} +0 -0
package/dist/openapi/index.js
CHANGED
package/package.json
CHANGED
package/template/AGENTS.md
CHANGED
|
@@ -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 `
|
|
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
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
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
|
-
// `
|
|
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
|
|
13
|
-
//
|
|
14
|
-
// and
|
|
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
|
-
// `
|
|
5
|
-
// an ordinary import path — so the shape is
|
|
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
|
|
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.
|
|
26
|
-
// grants nothing
|
|
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
|
|
29
|
-
//
|
|
30
|
-
// `
|
|
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
|
|
File without changes
|