@pikku/cli 0.12.54 → 0.12.56

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.
Files changed (267) hide show
  1. package/cli.schema.json +1 -1
  2. package/console-app/assets/{index-DYnbceYg.js → index-xN8LW0II.js} +155 -155
  3. package/console-app/index.html +1 -1
  4. package/dist/.pikku/agent/pikku-agent-types.gen.d.ts +1 -1
  5. package/dist/.pikku/channel/pikku-channel-types.gen.d.ts +3 -3
  6. package/dist/.pikku/channel/pikku-channel-types.gen.js +1 -1
  7. package/dist/.pikku/cli/pikku-cli-channel.d.ts +6 -6
  8. package/dist/.pikku/cli/pikku-cli-channel.js +11 -1
  9. package/dist/.pikku/cli/pikku-cli-client.gen.d.ts +1 -1
  10. package/dist/.pikku/cli/pikku-cli-client.gen.js +1 -1
  11. package/dist/.pikku/cli/pikku-cli-contracts-meta.gen.d.ts +1 -1
  12. package/dist/.pikku/cli/pikku-cli-contracts-meta.gen.js +1 -1
  13. package/dist/.pikku/cli/pikku-cli-contracts-meta.gen.json +14 -0
  14. package/dist/.pikku/cli/pikku-cli-types.gen.d.ts +1 -1
  15. package/dist/.pikku/cli/pikku-cli-types.gen.js +1 -1
  16. package/dist/.pikku/cli/pikku-cli-wirings-meta.gen.js +1 -1
  17. package/dist/.pikku/cli/pikku-cli-wirings-meta.gen.json +29 -0
  18. package/dist/.pikku/cli/pikku-cli-wirings.gen.d.ts +1 -1
  19. package/dist/.pikku/cli/pikku-cli-wirings.gen.js +1 -1
  20. package/dist/.pikku/cli/pikku-cli.gen.d.ts +1 -1
  21. package/dist/.pikku/cli/pikku-cli.gen.js +1 -1
  22. package/dist/.pikku/console/pikku-node-types.gen.d.ts +1 -1
  23. package/dist/.pikku/function/pikku-function-types.gen.d.ts +8 -31
  24. package/dist/.pikku/function/pikku-function-types.gen.js +1 -1
  25. package/dist/.pikku/function/pikku-functions-meta.gen.js +1 -1
  26. package/dist/.pikku/function/pikku-functions-meta.gen.json +1420 -1384
  27. package/dist/.pikku/function/pikku-functions.gen.js +3 -1
  28. package/dist/.pikku/http/pikku-http-types.gen.d.ts +1 -1
  29. package/dist/.pikku/http/pikku-http-types.gen.js +1 -1
  30. package/dist/.pikku/http/pikku-http-wirings-meta.gen.js +1 -1
  31. package/dist/.pikku/http/pikku-http-wirings.gen.d.ts +1 -1
  32. package/dist/.pikku/http/pikku-http-wirings.gen.js +1 -1
  33. package/dist/.pikku/mcp/pikku-mcp-types.gen.d.ts +1 -1
  34. package/dist/.pikku/mcp/pikku-mcp-types.gen.js +1 -1
  35. package/dist/.pikku/pikku-bootstrap.gen.d.ts +1 -1
  36. package/dist/.pikku/pikku-bootstrap.gen.js +1 -1
  37. package/dist/.pikku/pikku-meta-service.gen.d.ts +1 -1
  38. package/dist/.pikku/pikku-meta-service.gen.js +1 -1
  39. package/dist/.pikku/pikku-services.gen.d.ts +4 -2
  40. package/dist/.pikku/pikku-services.gen.js +2 -0
  41. package/dist/.pikku/pikku-types.gen.d.ts +1 -1
  42. package/dist/.pikku/pikku-types.gen.js +1 -1
  43. package/dist/.pikku/queue/pikku-queue-types.gen.d.ts +1 -1
  44. package/dist/.pikku/queue/pikku-queue-types.gen.js +1 -1
  45. package/dist/.pikku/queue/pikku-queue-workers-wirings-meta.gen.js +1 -1
  46. package/dist/.pikku/queue/pikku-queue-workers-wirings-meta.gen.json +0 -248
  47. package/dist/.pikku/queue/pikku-queue-workers-wirings.gen.d.ts +1 -1
  48. package/dist/.pikku/queue/pikku-queue-workers-wirings.gen.js +1 -1
  49. package/dist/.pikku/rpc/pikku-rpc-wirings-meta.internal.gen.js +1 -1
  50. package/dist/.pikku/rpc/pikku-rpc-wirings-meta.internal.gen.json +69 -67
  51. package/dist/.pikku/scheduler/pikku-scheduler-types.gen.d.ts +1 -1
  52. package/dist/.pikku/scheduler/pikku-scheduler-types.gen.js +1 -1
  53. package/dist/.pikku/schemas/register.gen.js +191 -185
  54. package/dist/.pikku/schemas/schemas/FabricAddonVerifyInput.schema.json +1 -0
  55. package/dist/.pikku/schemas/schemas/FabricAddonVerifyOutput.schema.json +1 -0
  56. package/dist/.pikku/schemas/schemas/PikkuAuthInput.schema.json +1 -0
  57. package/dist/.pikku/schemas/schemas/PikkuCLIConfig.schema.json +1 -1
  58. package/dist/.pikku/secrets/pikku-secret-types.gen.d.ts +1 -1
  59. package/dist/.pikku/secrets/pikku-secret-types.gen.js +1 -1
  60. package/dist/.pikku/secrets/pikku-secrets.gen.d.ts +1 -1
  61. package/dist/.pikku/secrets/pikku-secrets.gen.js +1 -1
  62. package/dist/.pikku/trigger/pikku-trigger-types.gen.d.ts +1 -1
  63. package/dist/.pikku/trigger/pikku-trigger-types.gen.js +1 -1
  64. package/dist/.pikku/variables/pikku-variable-types.gen.d.ts +1 -1
  65. package/dist/.pikku/variables/pikku-variable-types.gen.js +1 -1
  66. package/dist/.pikku/variables/pikku-variables.gen.d.ts +1 -1
  67. package/dist/.pikku/variables/pikku-variables.gen.js +1 -1
  68. package/dist/.pikku/workflow/meta/allWorkflow.gen.json +9 -3
  69. package/dist/.pikku/workflow/pikku-workflow-types.gen.d.ts +1 -1
  70. package/dist/.pikku/workflow/pikku-workflow-types.gen.js +1 -1
  71. package/dist/.pikku/workflow/pikku-workflow-wirings-meta.gen.js +1 -1
  72. package/dist/.pikku/workflow/pikku-workflow-wirings.gen.js +1 -1
  73. package/dist/bin/pikku-bin.mjs +2 -2
  74. package/dist/src/cli.wiring.js +15 -1
  75. package/dist/src/deploy/analyzer/analyzer.d.ts +6 -0
  76. package/dist/src/deploy/analyzer/analyzer.js +5 -4
  77. package/dist/src/deploy/build-pipeline.d.ts +5 -1
  78. package/dist/src/deploy/build-pipeline.js +5 -5
  79. package/dist/src/deploy/bundler/bun-bundler.d.ts +14 -0
  80. package/dist/src/deploy/bundler/bun-bundler.js +121 -0
  81. package/dist/src/deploy/bundler/bundler.d.ts +25 -30
  82. package/dist/src/deploy/bundler/bundler.interface.d.ts +54 -0
  83. package/dist/src/deploy/bundler/bundler.interface.js +11 -0
  84. package/dist/src/deploy/bundler/bundler.js +120 -190
  85. package/dist/src/deploy/bundler/dep-extractor.d.ts +11 -3
  86. package/dist/src/deploy/bundler/dep-extractor.js +12 -6
  87. package/dist/src/deploy/bundler/index.d.ts +5 -2
  88. package/dist/src/deploy/bundler/index.js +4 -2
  89. package/dist/src/deploy/bundler/node-bundler.d.ts +13 -0
  90. package/dist/src/deploy/bundler/node-bundler.js +80 -0
  91. package/dist/src/deploy/provider-adapter.d.ts +11 -0
  92. package/dist/src/deploy/server-entry.js +3 -1
  93. package/dist/src/fabric/fabric-commands.d.ts +109 -72
  94. package/dist/src/fabric/fabric-commands.js +8 -0
  95. package/dist/src/fabric/functions/add.function.d.ts +3 -3
  96. package/dist/src/fabric/functions/addon-verify.function.d.ts +54 -0
  97. package/dist/src/fabric/functions/addon-verify.function.js +153 -0
  98. package/dist/src/fabric/functions/db-schema.function.d.ts +3 -3
  99. package/dist/src/fabric/functions/deploy-list.function.d.ts +3 -3
  100. package/dist/src/fabric/functions/deploy-units.function.d.ts +3 -3
  101. package/dist/src/fabric/functions/deploy.function.d.ts +6 -6
  102. package/dist/src/fabric/functions/domains-add.function.d.ts +3 -3
  103. package/dist/src/fabric/functions/domains-list.function.d.ts +3 -3
  104. package/dist/src/fabric/functions/domains-remove.function.d.ts +3 -3
  105. package/dist/src/fabric/functions/errors.function.d.ts +3 -3
  106. package/dist/src/fabric/functions/init.function.d.ts +3 -3
  107. package/dist/src/fabric/functions/link.function.d.ts +3 -3
  108. package/dist/src/fabric/functions/llm-key.function.d.ts +3 -3
  109. package/dist/src/fabric/functions/llm-key.function.js +1 -1
  110. package/dist/src/fabric/functions/login.function.d.ts +3 -3
  111. package/dist/src/fabric/functions/logs.function.d.ts +3 -3
  112. package/dist/src/fabric/functions/metrics.function.d.ts +3 -3
  113. package/dist/src/fabric/functions/publish.function.d.ts +3 -3
  114. package/dist/src/fabric/functions/publish.function.js +8 -3
  115. package/dist/src/fabric/functions/rollback.function.d.ts +3 -3
  116. package/dist/src/fabric/functions/secrets-list.function.d.ts +3 -3
  117. package/dist/src/fabric/functions/secrets-set.function.d.ts +3 -3
  118. package/dist/src/fabric/functions/smoke.function.d.ts +3 -3
  119. package/dist/src/fabric/functions/status.function.d.ts +3 -3
  120. package/dist/src/fabric/functions/trace.function.d.ts +3 -3
  121. package/dist/src/fabric/functions/validate.function.d.ts +3 -3
  122. package/dist/src/functions/commands/all.d.ts +1 -1
  123. package/dist/src/functions/commands/all.js +19 -2
  124. package/dist/src/functions/commands/binary.d.ts +3 -3
  125. package/dist/src/functions/commands/bootstrap.d.ts +1 -1
  126. package/dist/src/functions/commands/bootstrap.js +3 -0
  127. package/dist/src/functions/commands/console.d.ts +3 -3
  128. package/dist/src/functions/commands/db-audit.d.ts +1 -1
  129. package/dist/src/functions/commands/db-generate.d.ts +1 -1
  130. package/dist/src/functions/commands/db-migrate.d.ts +1 -1
  131. package/dist/src/functions/commands/db-reset.d.ts +1 -1
  132. package/dist/src/functions/commands/db-seed.d.ts +1 -1
  133. package/dist/src/functions/commands/deploy-apply.d.ts +3 -3
  134. package/dist/src/functions/commands/deploy-apply.js +32 -1
  135. package/dist/src/functions/commands/deploy-info.d.ts +1 -1
  136. package/dist/src/functions/commands/deploy-plan.d.ts +3 -3
  137. package/dist/src/functions/commands/deploy-plan.js +3 -1
  138. package/dist/src/functions/commands/dev.d.ts +3 -3
  139. package/dist/src/functions/commands/dev.js +17 -45
  140. package/dist/src/functions/commands/emails-init.d.ts +1 -1
  141. package/dist/src/functions/commands/enable.d.ts +6 -5
  142. package/dist/src/functions/commands/enable.js +4 -0
  143. package/dist/src/functions/commands/info.d.ts +4 -4
  144. package/dist/src/functions/commands/login.d.ts +7 -7
  145. package/dist/src/functions/commands/meta.d.ts +31 -31
  146. package/dist/src/functions/commands/new-addon.d.ts +3 -3
  147. package/dist/src/functions/commands/new-function.d.ts +3 -3
  148. package/dist/src/functions/commands/new-middleware.d.ts +3 -3
  149. package/dist/src/functions/commands/new-permission.d.ts +3 -3
  150. package/dist/src/functions/commands/new-wiring.d.ts +3 -3
  151. package/dist/src/functions/commands/pikku-command-bootstrap.d.ts +1 -1
  152. package/dist/src/functions/commands/pikku-command-summary.d.ts +1 -1
  153. package/dist/src/functions/commands/pikku-command-summary.js +6 -1
  154. package/dist/src/functions/commands/skills.d.ts +6 -6
  155. package/dist/src/functions/commands/tests-coverage.d.ts +3 -3
  156. package/dist/src/functions/commands/tests-init.d.ts +3 -3
  157. package/dist/src/functions/commands/versions-check.d.ts +1 -1
  158. package/dist/src/functions/commands/versions-init.d.ts +3 -3
  159. package/dist/src/functions/commands/versions-update.d.ts +1 -1
  160. package/dist/src/functions/commands/watch.d.ts +3 -3
  161. package/dist/src/functions/commands/workspace-validate.d.ts +3 -3
  162. package/dist/src/functions/db/db-codegen.js +14 -0
  163. package/dist/src/functions/db/sqlite/sqlite-runtime-bun.js +10 -0
  164. package/dist/src/functions/runtimes/fetch/index.d.ts +1 -1
  165. package/dist/src/functions/runtimes/nextjs/pikku-command-nextjs.d.ts +1 -1
  166. package/dist/src/functions/runtimes/tanstack-start/pikku-command-tanstack-start.d.ts +1 -1
  167. package/dist/src/functions/runtimes/websocket/pikku-command-websocket-typed.d.ts +1 -1
  168. package/dist/src/functions/wirings/ai-agent/pikku-command-ai-agent-types.d.ts +1 -1
  169. package/dist/src/functions/wirings/ai-agent/pikku-command-ai-agent.d.ts +1 -1
  170. package/dist/src/functions/wirings/ai-agent/pikku-command-public-agent.d.ts +1 -1
  171. package/dist/src/functions/wirings/auth/pikku-command-auth.d.ts +7 -1
  172. package/dist/src/functions/wirings/auth/pikku-command-auth.js +14 -2
  173. package/dist/src/functions/wirings/auth/serialize-auth-types.d.ts +10 -0
  174. package/dist/src/functions/wirings/auth/serialize-auth-types.js +15 -0
  175. package/dist/src/functions/wirings/channels/pikku-channels.d.ts +1 -1
  176. package/dist/src/functions/wirings/channels/pikku-command-channel-types.d.ts +1 -1
  177. package/dist/src/functions/wirings/channels/pikku-command-channels-map.d.ts +1 -1
  178. package/dist/src/functions/wirings/channels/pikku-command-channels.d.ts +1 -1
  179. package/dist/src/functions/wirings/cli/pikku-command-cli-entry.d.ts +1 -1
  180. package/dist/src/functions/wirings/cli/pikku-command-cli-types.d.ts +1 -1
  181. package/dist/src/functions/wirings/cli/pikku-command-cli.d.ts +1 -1
  182. package/dist/src/functions/wirings/console/pikku-command-console-functions.d.ts +1 -1
  183. package/dist/src/functions/wirings/console/pikku-command-node-types.d.ts +1 -1
  184. package/dist/src/functions/wirings/console/pikku-command-nodes-meta.d.ts +1 -1
  185. package/dist/src/functions/wirings/credentials/pikku-command-credentials.d.ts +1 -1
  186. package/dist/src/functions/wirings/emails/pikku-command-emails.d.ts +1 -1
  187. package/dist/src/functions/wirings/functions/pikku-command-addon-types.d.ts +1 -1
  188. package/dist/src/functions/wirings/functions/pikku-command-function-types-split.d.ts +3 -3
  189. package/dist/src/functions/wirings/functions/pikku-command-function-types.d.ts +3 -3
  190. package/dist/src/functions/wirings/functions/pikku-command-function-types.js +10 -3
  191. package/dist/src/functions/wirings/functions/pikku-command-functions.d.ts +1 -1
  192. package/dist/src/functions/wirings/functions/pikku-command-services.d.ts +1 -1
  193. package/dist/src/functions/wirings/functions/schemas.d.ts +1 -1
  194. package/dist/src/functions/wirings/functions/serialize-function-types.js +6 -29
  195. package/dist/src/functions/wirings/gateway/pikku-command-gateway.d.ts +1 -1
  196. package/dist/src/functions/wirings/http/pikku-command-http-map.d.ts +1 -1
  197. package/dist/src/functions/wirings/http/pikku-command-http-routes.d.ts +1 -1
  198. package/dist/src/functions/wirings/http/pikku-command-http-types.d.ts +1 -1
  199. package/dist/src/functions/wirings/http/pikku-command-openapi.d.ts +1 -1
  200. package/dist/src/functions/wirings/http/pikku-http-routes.d.ts +1 -1
  201. package/dist/src/functions/wirings/mcp/pikku-command-mcp-json.d.ts +1 -1
  202. package/dist/src/functions/wirings/mcp/pikku-command-mcp-types.d.ts +1 -1
  203. package/dist/src/functions/wirings/mcp/pikku-command-mcp.d.ts +1 -1
  204. package/dist/src/functions/wirings/middleware/pikku-command-middleware.d.ts +1 -1
  205. package/dist/src/functions/wirings/package/pikku-command-package-types.d.ts +2 -2
  206. package/dist/src/functions/wirings/package/pikku-command-package.d.ts +1 -1
  207. package/dist/src/functions/wirings/permissions/pikku-command-permissions.d.ts +1 -1
  208. package/dist/src/functions/wirings/queue/pikku-command-queue-map.d.ts +1 -1
  209. package/dist/src/functions/wirings/queue/pikku-command-queue-service.d.ts +1 -1
  210. package/dist/src/functions/wirings/queue/pikku-command-queue-types.d.ts +1 -1
  211. package/dist/src/functions/wirings/queue/pikku-command-queue.d.ts +1 -1
  212. package/dist/src/functions/wirings/queue/pikku-queue-map.d.ts +1 -1
  213. package/dist/src/functions/wirings/queue/pikku-queue.d.ts +1 -1
  214. package/dist/src/functions/wirings/realtime/pikku-command-events-scaffold.d.ts +1 -1
  215. package/dist/src/functions/wirings/realtime/pikku-command-realtime.d.ts +1 -1
  216. package/dist/src/functions/wirings/rpc/pikku-command-public-rpc.d.ts +1 -1
  217. package/dist/src/functions/wirings/rpc/pikku-command-react-query.d.ts +1 -1
  218. package/dist/src/functions/wirings/rpc/pikku-command-remote-rpc.d.ts +1 -1
  219. package/dist/src/functions/wirings/rpc/pikku-command-rpc-client.d.ts +1 -1
  220. package/dist/src/functions/wirings/rpc/pikku-command-rpc-map.d.ts +2 -2
  221. package/dist/src/functions/wirings/rpc/pikku-command-rpc.d.ts +1 -1
  222. package/dist/src/functions/wirings/scheduler/pikku-command-scheduler-types.d.ts +1 -1
  223. package/dist/src/functions/wirings/scheduler/pikku-command-scheduler.d.ts +1 -1
  224. package/dist/src/functions/wirings/secrets/pikku-command-secrets.d.ts +1 -1
  225. package/dist/src/functions/wirings/triggers/pikku-command-trigger-types.d.ts +3 -3
  226. package/dist/src/functions/wirings/triggers/pikku-command-trigger.d.ts +1 -1
  227. package/dist/src/functions/wirings/variables/pikku-command-variables.d.ts +1 -1
  228. package/dist/src/functions/wirings/workflow/pikku-command-workflow-routes.d.ts +1 -1
  229. package/dist/src/functions/wirings/workflow/pikku-command-workflow.d.ts +1 -1
  230. package/dist/src/functions/workflows/all.workflow.js +6 -1
  231. package/dist/src/scaffold/rpc-remote.gen.d.ts +3 -3
  232. package/dist/src/scaffold/rpc-remote.gen.js +1 -1
  233. package/dist/src/server/bun-server-runner.d.ts +17 -0
  234. package/dist/src/server/bun-server-runner.js +25 -0
  235. package/dist/src/server/dev-server-runner.interface.d.ts +31 -0
  236. package/dist/src/server/dev-server-runner.interface.js +11 -0
  237. package/dist/src/server/node-server-runner.d.ts +12 -0
  238. package/dist/src/server/node-server-runner.js +30 -0
  239. package/dist/src/services/cli-logger.service.js +7 -1
  240. package/dist/src/services.js +18 -0
  241. package/dist/src/utils/detect-better-auth.d.ts +7 -0
  242. package/dist/src/utils/detect-better-auth.js +29 -0
  243. package/dist/src/utils/parse-cli-filters.d.ts +1 -0
  244. package/dist/src/utils/parse-cli-filters.js +1 -0
  245. package/dist/src/utils/pikku-cli-config.js +1 -1
  246. package/dist/src/utils/serialize-schemas.js +5 -1
  247. package/dist/tsconfig.tsbuildinfo +1 -1
  248. package/package.json +4 -4
  249. package/skills/pikku-addon/SKILL.md +25 -117
  250. package/skills/pikku-addon/references/addon-package-manifest.md +63 -0
  251. package/skills/pikku-cli/SKILL.md +7 -93
  252. package/skills/pikku-cli/references/complete-example.md +82 -0
  253. package/skills/pikku-concepts/SKILL.md +17 -69
  254. package/skills/pikku-concepts/references/concept-mapping.md +37 -13
  255. package/skills/pikku-concepts/references/packages.md +29 -0
  256. package/skills/pikku-http/SKILL.md +14 -105
  257. package/skills/pikku-http/references/http-options.md +57 -0
  258. package/skills/pikku-middleware/SKILL.md +11 -68
  259. package/skills/pikku-middleware/references/middleware-patterns.md +61 -0
  260. package/skills/pikku-realtime/SKILL.md +56 -105
  261. package/skills/pikku-realtime/references/other-routes.md +23 -0
  262. package/skills/pikku-services/SKILL.md +25 -108
  263. package/skills/pikku-services/references/audit-wire-service.md +34 -0
  264. package/skills/pikku-testing/SKILL.md +51 -359
  265. package/skills/pikku-testing/references/cucumber-bdd-testing.md +176 -0
  266. package/skills/pikku-workflow/SKILL.md +93 -259
  267. package/skills/pikku-workflow/references/workflow-reference.md +63 -0
@@ -172,110 +172,24 @@ wireCLI({
172
172
 
173
173
  ### Custom Renderers
174
174
 
175
+ A renderer receives `(services, data)` where `data` is the func's output. Set `render` on `wireCLI` as the program-wide default; set `render` on a `pikkuCLICommand` to override it for that command.
176
+
175
177
  ```typescript
176
178
  const todoRenderer = pikkuCLIRender<{ todo: Todo }>((_services, { todo }) => {
177
179
  console.log(`✓ Created: ${todo.text} (priority: ${todo.priority})`)
178
180
  })
179
181
 
180
- const todosRenderer = pikkuCLIRender<{ todos: Todo[] }>(
181
- (_services, { todos }) => {
182
- todos.forEach((t, i) => {
183
- const check = t.completed ? '✓' : ' '
184
- console.log(` ${i + 1}. ${t.text} ${check}`)
185
- })
186
- }
187
- )
188
-
189
- // Default renderer for program, override per-command
190
182
  wireCLI({
191
183
  program: 'todos',
192
- render: jsonRenderer,
184
+ render: jsonRenderer, // default for all commands
193
185
  commands: {
194
- add: pikkuCLICommand({
195
- func: createTodo,
196
- render: todoRenderer, // Overrides jsonRenderer
197
- }),
186
+ add: pikkuCLICommand({ func: createTodo, render: todoRenderer }), // overrides jsonRenderer
198
187
  },
199
188
  })
200
189
  ```
201
190
 
202
- ## Complete Example
203
-
204
- ```typescript
205
- // functions/admin.functions.ts
206
- export const createUser = pikkuFunc({
207
- title: 'Create User',
208
- func: async ({ db }, { username, email, admin }) => {
209
- const user = await db.createUser({
210
- username,
211
- email,
212
- role: admin ? 'admin' : 'user',
213
- })
214
- return { user }
215
- },
216
- })
217
-
218
- export const listUsers = pikkuSessionlessFunc({
219
- title: 'List Users',
220
- func: async ({ db }, { limit }) => {
221
- return { users: await db.listUsers(limit || 50) }
222
- },
223
- })
224
-
225
- export const deleteUser = pikkuFunc({
226
- title: 'Delete User',
227
- func: async ({ db }, { username }) => {
228
- await db.deleteUser(username)
229
- return { deleted: username }
230
- },
231
- })
191
+ The func's input is the positional `parameters` plus `options`, merged (e.g. `parameters: '<username> <email>'` + an `admin` option → func input `{ username, email, admin }`).
232
192
 
233
- // wirings/cli.wiring.ts
234
- const userRenderer = pikkuCLIRender<{ user: User }>((_services, { user }) => {
235
- console.log(`Created user: ${user.username} (${user.email}) [${user.role}]`)
236
- })
237
-
238
- const usersRenderer = pikkuCLIRender<{ users: User[] }>(
239
- (_services, { users }) => {
240
- console.log(`Users (${users.length}):`)
241
- users.forEach((u) =>
242
- console.log(` ${u.username} <${u.email}> [${u.role}]`)
243
- )
244
- }
245
- )
193
+ ## Complete Example
246
194
 
247
- wireCLI({
248
- program: 'admin',
249
- commands: {
250
- user: {
251
- description: 'User management',
252
- subcommands: {
253
- create: pikkuCLICommand({
254
- parameters: '<username> <email>',
255
- func: createUser,
256
- render: userRenderer,
257
- options: {
258
- admin: {
259
- description: 'Create as admin',
260
- short: 'a',
261
- default: false,
262
- },
263
- },
264
- }),
265
- list: pikkuCLICommand({
266
- func: listUsers,
267
- render: usersRenderer,
268
- options: {
269
- limit: { description: 'Max results', short: 'l' },
270
- },
271
- }),
272
- delete: pikkuCLICommand({
273
- parameters: '<username>',
274
- func: deleteUser,
275
- description: 'Delete a user',
276
- }),
277
- },
278
- },
279
- },
280
- })
281
- ```
195
+ For a full functions + renderers + nested-subcommand wiring walkthrough, see `references/complete-example.md`.
@@ -0,0 +1,82 @@
1
+ # Complete CLI Example
2
+
3
+ End-to-end: functions + renderers + nested-subcommand wiring. Note how each func's input is the positional `parameters` plus `options`, merged (e.g. `parameters: '<username> <email>'` + option `admin` → func input `{ username, email, admin }`).
4
+
5
+ ```typescript
6
+ // functions/admin.functions.ts
7
+ export const createUser = pikkuFunc({
8
+ title: 'Create User',
9
+ func: async ({ db }, { username, email, admin }) => {
10
+ const user = await db.createUser({
11
+ username,
12
+ email,
13
+ role: admin ? 'admin' : 'user',
14
+ })
15
+ return { user }
16
+ },
17
+ })
18
+
19
+ export const listUsers = pikkuSessionlessFunc({
20
+ title: 'List Users',
21
+ func: async ({ db }, { limit }) => {
22
+ return { users: await db.listUsers(limit || 50) }
23
+ },
24
+ })
25
+
26
+ export const deleteUser = pikkuFunc({
27
+ title: 'Delete User',
28
+ func: async ({ db }, { username }) => {
29
+ await db.deleteUser(username)
30
+ return { deleted: username }
31
+ },
32
+ })
33
+
34
+ // wirings/cli.wiring.ts
35
+ const userRenderer = pikkuCLIRender<{ user: User }>((_services, { user }) => {
36
+ console.log(`Created user: ${user.username} (${user.email}) [${user.role}]`)
37
+ })
38
+
39
+ const usersRenderer = pikkuCLIRender<{ users: User[] }>(
40
+ (_services, { users }) => {
41
+ console.log(`Users (${users.length}):`)
42
+ users.forEach((u) =>
43
+ console.log(` ${u.username} <${u.email}> [${u.role}]`)
44
+ )
45
+ }
46
+ )
47
+
48
+ wireCLI({
49
+ program: 'admin',
50
+ commands: {
51
+ user: {
52
+ description: 'User management',
53
+ subcommands: {
54
+ create: pikkuCLICommand({
55
+ parameters: '<username> <email>',
56
+ func: createUser,
57
+ render: userRenderer,
58
+ options: {
59
+ admin: {
60
+ description: 'Create as admin',
61
+ short: 'a',
62
+ default: false,
63
+ },
64
+ },
65
+ }),
66
+ list: pikkuCLICommand({
67
+ func: listUsers,
68
+ render: usersRenderer,
69
+ options: {
70
+ limit: { description: 'Max results', short: 'l' },
71
+ },
72
+ }),
73
+ delete: pikkuCLICommand({
74
+ parameters: '<username>',
75
+ func: deleteUser,
76
+ description: 'Delete a user',
77
+ }),
78
+ },
79
+ },
80
+ },
81
+ })
82
+ ```
@@ -53,42 +53,32 @@ The function never imports Express, never reads `req.body`, never touches `ws.se
53
53
 
54
54
  ## Concept Mapping: Generic Backend → Pikku
55
55
 
56
- | Generic Backend Concept | Pikku Equivalent | Skill |
57
- | --------------------------------------- | --------------------------------------------------------------- | ----------------- |
58
- | **Controller / Route Handler** | `pikkuFunc` / `pikkuSessionlessFunc` | (this skill) |
59
- | **Route definition** (`GET /users/:id`) | `wireHTTP({ route, method, func })` | `pikku-http` |
60
- | **Middleware** (Express/Koa-style) | `pikkuMiddleware` | `pikku-security` |
61
- | **Auth Guard / Auth Middleware** | `authBearer()` / `authCookie()` / `authApiKey()` | `pikku-security` |
62
- | **Authorization / Permissions** | `pikkuPermission` / `pikkuAuth` | `pikku-security` |
63
- | **DTO / Request Validation** | Standard Schema (Zod, Valibot, ArkType) | (this skill) |
64
- | **Dependency Injection** | `pikkuServices` (singleton) + `pikkuWireServices` (per-request) | `pikku-services` |
65
- | **WebSocket handlers** | `wireChannel` | `pikku-websocket` |
66
- | **Job Queue workers** | `wireQueueWorker` | `pikku-queue` |
67
- | **Cron / Scheduled tasks** | `wireScheduler` | `pikku-cron` |
68
- | **Module / Feature grouping** | Tags + wiring files | (this skill) |
69
- | **Error handling** | Throw typed errors (`NotFoundError`, `ForbiddenError`) | (this skill) |
70
- | **Type-safe API client** | `npx pikku prebuild` generates clients | (this skill) |
71
- | **Secrets / Config** | `wireSecret`, `wireVariable`, `services.variables` | `pikku-config` |
56
+ Controllers/routes → `pikkuFunc`; middleware/auth/permissions → `pikku-security`; DI → `pikku-services`; transports (HTTP/WS/queue/cron) → their `wire*` + skill. For the full Generic Backend Pikku mapping table (with side-by-side code examples), read `references/concept-mapping.md`.
72
57
 
73
58
  ## Functions
74
59
 
75
60
  Three main function types:
76
61
 
77
62
  ```typescript
78
- // Requires authentication — receives session in wire context
79
- const updateTodo = pikkuFunc<UpdateInput, TodoOutput>(
80
- async (services, data, wire) => {
63
+ // Requires authentication — receives session in wire context.
64
+ // input/output are Zod schemas; the data + return types are inferred from them.
65
+ const updateTodo = pikkuFunc({
66
+ input: UpdateTodoInput,
67
+ output: TodoOutput,
68
+ func: async (services, data, wire) => {
81
69
  const session = await wire.session.get()
82
70
  return services.todoStore.update(data.id, data)
83
- }
84
- )
71
+ },
72
+ })
85
73
 
86
74
  // No authentication required
87
- const listTodos = pikkuSessionlessFunc<ListInput, TodoListOutput>(
88
- async (services, data) => {
75
+ const listTodos = pikkuSessionlessFunc({
76
+ input: ListTodosInput,
77
+ output: TodoListOutput,
78
+ func: async (services, data) => {
89
79
  return { todos: services.todoStore.list(data.filters) }
90
- }
91
- )
80
+ },
81
+ })
92
82
 
93
83
  // No input or output (for scheduled tasks, lifecycle hooks)
94
84
  const cleanup = pikkuVoidFunc(async (services) => {
@@ -96,23 +86,7 @@ const cleanup = pikkuVoidFunc(async (services) => {
96
86
  })
97
87
  ```
98
88
 
99
- Config object form (recommended):
100
-
101
- ```typescript
102
- const createTodo = pikkuSessionlessFunc({
103
- title: 'Create Todo',
104
- description: 'Create a new todo item',
105
- input: CreateTodoInputSchema,
106
- output: CreateTodoOutputSchema,
107
- func: async ({ logger, todoStore }, { title, priority }) => {
108
- const todo = todoStore.createTodo(title, priority)
109
- logger.info(`Created todo: ${todo.id}`)
110
- return { todo }
111
- },
112
- })
113
- ```
114
-
115
- Full config options:
89
+ Services can be destructured inline in the `func` signature (e.g. `async ({ logger, todoStore }, { title }) => ...`). Full config options:
116
90
 
117
91
  ```typescript
118
92
  pikkuFunc({
@@ -243,33 +217,7 @@ expect(result.todos).toHaveLength(3)
243
217
 
244
218
  ## Available Packages
245
219
 
246
- ### Runtime Adapters
247
-
248
- | Package | Use Case |
249
- | ----------------------------- | ------------------------------------- |
250
- | `@pikku/express-server` | Express standalone server |
251
- | `@pikku/express-middleware` | Express as middleware in existing app |
252
- | `@pikku/fastify-server` | Fastify standalone |
253
- | `@pikku/fastify-plugin` | Fastify plugin |
254
- | `@pikku/next` | Next.js API routes |
255
- | `@pikku/aws-lambda` | AWS Lambda handlers |
256
- | `@pikku/cloudflare` | Cloudflare Workers |
257
- | `@pikku/uws-server` | uWebSockets.js (high perf) |
258
- | `@pikku/modelcontextprotocol` | MCP server |
259
-
260
- ### Service Packages
261
-
262
- | Package | Provides |
263
- | ------------------------ | ---------------------------------------------------- |
264
- | `@pikku/jose` | JWT (sign/verify) via jose library |
265
- | `@pikku/schema-ajv` | Schema validation via AJV |
266
- | `@pikku/schema-cfworker` | Schema validation for Cloudflare |
267
- | `@pikku/pino` | Structured logging via Pino |
268
- | `@pikku/kysely` | Type-safe SQL via Kysely (PostgreSQL, SQLite, MySQL) |
269
- | `@pikku/redis` | Redis client |
270
- | `@pikku/queue-bullmq` | Job queues via BullMQ |
271
- | `@pikku/queue-pg-boss` | Job queues via PgBoss |
272
- | `@pikku/aws-services` | AWS SDK (SQS, DynamoDB, etc.) |
220
+ Pikku ships runtime adapters (`@pikku/express-server`, `@pikku/fastify-server`, `@pikku/next`, `@pikku/aws-lambda`, `@pikku/cloudflare`, `@pikku/uws-server`, `@pikku/modelcontextprotocol`, ...) and service packages (`@pikku/jose`, `@pikku/schema-ajv`, `@pikku/pino`, `@pikku/kysely`, `@pikku/redis`, `@pikku/queue-bullmq`, `@pikku/queue-pg-boss`, ...). For the full list with use cases, read `references/packages.md`.
273
221
 
274
222
  ## Key Differences from Traditional Frameworks
275
223
 
@@ -1,6 +1,25 @@
1
1
  # Concept Mapping: Generic Backend → Pikku
2
2
 
3
- Side-by-side code examples showing how common backend patterns translate to Pikku.
3
+ Authoritative mapping table plus side-by-side code examples showing how common backend patterns translate to Pikku.
4
+
5
+ ## Quick Reference Table
6
+
7
+ | Generic Backend Concept | Pikku Equivalent | Skill |
8
+ | --------------------------------------- | --------------------------------------------------------------- | ----------------- |
9
+ | **Controller / Route Handler** | `pikkuFunc` / `pikkuSessionlessFunc` | `pikku-concepts` |
10
+ | **Route definition** (`GET /users/:id`) | `wireHTTP({ route, method, func })` | `pikku-http` |
11
+ | **Middleware** (Express/Koa-style) | `pikkuMiddleware` | `pikku-security` |
12
+ | **Auth Guard / Auth Middleware** | `authBearer()` / `authCookie()` / `authApiKey()` | `pikku-security` |
13
+ | **Authorization / Permissions** | `pikkuPermission` / `pikkuAuth` | `pikku-security` |
14
+ | **DTO / Request Validation** | Standard Schema (Zod, Valibot, ArkType) | `pikku-concepts` |
15
+ | **Dependency Injection** | `pikkuServices` (singleton) + `pikkuWireServices` (per-request) | `pikku-services` |
16
+ | **WebSocket handlers** | `wireChannel` | `pikku-websocket` |
17
+ | **Job Queue workers** | `wireQueueWorker` | `pikku-queue` |
18
+ | **Cron / Scheduled tasks** | `wireScheduler` | `pikku-cron` |
19
+ | **Module / Feature grouping** | Tags + wiring files | `pikku-concepts` |
20
+ | **Error handling** | Throw typed errors (`NotFoundError`, `ForbiddenError`) | `pikku-concepts` |
21
+ | **Type-safe API client** | `npx pikku prebuild` generates clients | `pikku-concepts` |
22
+ | **Secrets / Config** | `wireSecret`, `wireVariable`, `services.variables` | `pikku-config` |
4
23
 
5
24
  ## Route Handler / Controller → pikkuFunc
6
25
 
@@ -21,14 +40,17 @@ class TodoController {
21
40
  **Pikku:**
22
41
 
23
42
  ```typescript
24
- // Function knows nothing about HTTP
25
- const createTodo = pikkuSessionlessFunc<CreateTodoInput, TodoOutput>(
26
- async ({ todoStore, logger }, { title, priority }) => {
43
+ // Function knows nothing about HTTP.
44
+ // input/output are Zod schemas; the data + return types are inferred from them.
45
+ const createTodo = pikkuSessionlessFunc({
46
+ input: CreateTodoInput,
47
+ output: TodoOutput,
48
+ func: async ({ todoStore, logger }, { title, priority }) => {
27
49
  const todo = todoStore.createTodo(title, priority)
28
50
  logger.info(`Created todo: ${todo.id}`)
29
51
  return { todo }
30
- }
31
- )
52
+ },
53
+ })
32
54
 
33
55
  // Wiring (separate file) - grouped with defineHTTPRoutes
34
56
  export const todoRoutes = defineHTTPRoutes({
@@ -68,13 +90,15 @@ async getUser(req: Request, res: Response) {
68
90
  **Pikku:**
69
91
 
70
92
  ```typescript
71
- // All sources merged into a single typed `data` object
72
- const getUser = pikkuSessionlessFunc<
73
- { id: string; fields?: string },
74
- UserOutput
75
- >(async (services, { id, fields }) => {
76
- // id comes from route param, fields from query - function doesn't care
77
- return { user: await services.db.getUser(id, fields) }
93
+ // All sources merged into a single typed `data` object.
94
+ // input/output are Zod schemas; the data + return types are inferred from them.
95
+ const getUser = pikkuSessionlessFunc({
96
+ input: z.object({ id: z.string(), fields: z.string().optional() }),
97
+ output: UserOutput,
98
+ func: async (services, { id, fields }) => {
99
+ // id comes from route param, fields from query - function doesn't care
100
+ return { user: await services.db.getUser(id, fields) }
101
+ },
78
102
  })
79
103
 
80
104
  wireHTTP({ method: 'get', route: '/users/:id', func: getUser, auth: false })
@@ -0,0 +1,29 @@
1
+ # Available Pikku Packages
2
+
3
+ ## Runtime Adapters
4
+
5
+ | Package | Use Case |
6
+ | ----------------------------- | ------------------------------------- |
7
+ | `@pikku/express-server` | Express standalone server |
8
+ | `@pikku/express-middleware` | Express as middleware in existing app |
9
+ | `@pikku/fastify-server` | Fastify standalone |
10
+ | `@pikku/fastify-plugin` | Fastify plugin |
11
+ | `@pikku/next` | Next.js API routes |
12
+ | `@pikku/aws-lambda` | AWS Lambda handlers |
13
+ | `@pikku/cloudflare` | Cloudflare Workers |
14
+ | `@pikku/uws-server` | uWebSockets.js (high perf) |
15
+ | `@pikku/modelcontextprotocol` | MCP server |
16
+
17
+ ## Service Packages
18
+
19
+ | Package | Provides |
20
+ | ------------------------ | ---------------------------------------------------- |
21
+ | `@pikku/jose` | JWT (sign/verify) via jose library |
22
+ | `@pikku/schema-ajv` | Schema validation via AJV |
23
+ | `@pikku/schema-cfworker` | Schema validation for Cloudflare |
24
+ | `@pikku/pino` | Structured logging via Pino |
25
+ | `@pikku/kysely` | Type-safe SQL via Kysely (PostgreSQL, SQLite, MySQL) |
26
+ | `@pikku/redis` | Redis client |
27
+ | `@pikku/queue-bullmq` | Job queues via BullMQ |
28
+ | `@pikku/queue-pg-boss` | Job queues via PgBoss |
29
+ | `@pikku/aws-services` | AWS SDK (SQS, DynamoDB, etc.) |
@@ -34,67 +34,14 @@ Follow existing patterns you find (naming, tag usage, file organization). See `p
34
34
 
35
35
  ## API Reference
36
36
 
37
- ### `wireHTTP(config)`
37
+ - `wireHTTP(config)` (from `@pikku/core/http`) — wire one function to one endpoint.
38
+ - `defineHTTPRoutes(config)` + `wireHTTPRoutes(config)` (from `.pikku/pikku-types.gen.js`) — group routes with shared config; composable/nestable.
38
39
 
39
- Wire a single function to an HTTP endpoint.
40
+ Function input/output types come from the function's own `input:`/`output:` zod schemas — never declared in the wiring. Route `:params`, query params, and body are merged into the function's `data` arg (see Data Flow).
40
41
 
41
- ```typescript
42
- import { wireHTTP } from '@pikku/core/http'
43
-
44
- wireHTTP({
45
- method: 'get' | 'post' | 'put' | 'patch' | 'delete' | 'head',
46
- route: string, // e.g. '/books/:bookId' — :params become data fields
47
- func: PikkuFunc, // The function to call
48
- auth?: boolean, // Override default auth (true = require session)
49
- tags?: string[], // For grouping, middleware targeting
50
- permissions?: Record<string, PikkuPermission | PikkuPermission[]>,
51
- middleware?: PikkuMiddleware[],
52
- sse?: boolean, // Enable Server-Sent Events
53
- contentType?: 'xml' | 'json', // Response content type
54
- timeout?: number, // Request timeout in ms
55
- headers?: HTTPHeadersSchema, // Expected headers schema
56
- docs?: HTTPRouteDocsConfig, // OpenAPI docs config
57
- })
58
- ```
59
-
60
- ### `defineHTTPRoutes(config)` + `wireHTTPRoutes(config)`
42
+ Config cascading across groups: `basePath` concatenates down the chain, `tags` merge (union), `auth` child overrides parent.
61
43
 
62
- Group routes with shared configuration. Groups are composable and nestable.
63
-
64
- ```typescript
65
- import { defineHTTPRoutes, wireHTTPRoutes } from '.pikku/pikku-types.gen.js'
66
-
67
- const routes = defineHTTPRoutes({
68
- basePath?: string, // Prepended to all route paths
69
- tags?: string[], // Applied to all routes in group
70
- auth?: boolean, // Default auth for all routes (overridable per-route)
71
- middleware?: PikkuMiddleware[],
72
- routes: {
73
- [key: string]: {
74
- method: string,
75
- route: string,
76
- func: PikkuFunc,
77
- auth?: boolean, // Override group auth
78
- permissions?: Record<string, PikkuPermission | PikkuPermission[]>,
79
- middleware?: PikkuMiddleware[],
80
- }
81
- }
82
- })
83
-
84
- wireHTTPRoutes({
85
- basePath?: string, // Top-level prefix (e.g. '/api/v1')
86
- middleware?: PikkuMiddleware[],
87
- routes: {
88
- [key: string]: ReturnType<typeof defineHTTPRoutes>,
89
- }
90
- })
91
- ```
92
-
93
- Config cascading rules:
94
-
95
- - `basePath` — concatenates down the chain
96
- - `tags` — merge (union)
97
- - `auth` — child overrides parent
44
+ For the full option tables (every `wireHTTP` field, the `defineHTTPRoutes`/`wireHTTPRoutes` config shape), read `references/http-options.md`.
98
45
 
99
46
  ### `addHTTPMiddleware(pattern, middlewares)`
100
47
 
@@ -137,7 +84,7 @@ wireHTTP({
137
84
  const booksRoutes = defineHTTPRoutes({
138
85
  tags: ['books'],
139
86
  routes: {
140
- list: { method: 'get', route: '/books', func: listBooks, auth: false },
87
+ list: { method: 'get', route: '/books', func: listBooks, auth: false }, // per-route override
141
88
  get: { method: 'get', route: '/books/:bookId', func: getBook },
142
89
  create: { method: 'post', route: '/books', func: createBook },
143
90
  delete: { method: 'delete', route: '/books/:bookId', func: deleteBook },
@@ -145,24 +92,19 @@ const booksRoutes = defineHTTPRoutes({
145
92
  })
146
93
 
147
94
  const todosRoutes = defineHTTPRoutes({
148
- auth: false,
95
+ auth: false, // group-level default, overridable per-route
149
96
  tags: ['todos'],
150
97
  routes: {
151
98
  list: { method: 'get', route: '/todos', func: listTodos },
152
- create: { method: 'post', route: '/todos', func: createTodo },
153
- get: { method: 'get', route: '/todos/:id', func: getTodo },
154
99
  },
155
100
  })
156
101
 
157
102
  wireHTTPRoutes({
158
103
  basePath: '/api/v1',
159
104
  middleware: [cors()],
160
- routes: {
161
- books: booksRoutes,
162
- todos: todosRoutes,
163
- },
105
+ routes: { books: booksRoutes, todos: todosRoutes },
164
106
  })
165
- // Results in: GET /api/v1/books, POST /api/v1/books, etc.
107
+ // Results in: GET /api/v1/books, POST /api/v1/books, GET /api/v1/todos, etc.
166
108
  ```
167
109
 
168
110
  ### Auth & Permissions
@@ -258,60 +200,27 @@ const deleted = await pikkuFetch.delete('/api/v1/books/:bookId', {
258
200
 
259
201
  ## Complete Example
260
202
 
203
+ Functions live in their own files (one per file) and supply behavior + `permissions`; the wiring file imports them and wires routes. Sessionless funcs need no session; `pikkuFunc` does.
204
+
261
205
  ```typescript
262
206
  // functions/books.functions.ts
263
207
  import { pikkuFunc, pikkuSessionlessFunc } from '#pikku'
264
208
 
265
209
  export const listBooks = pikkuSessionlessFunc({
266
210
  title: 'List Books',
267
- func: async ({ db }, { limit }) => {
268
- return { books: await db.listBooks(limit) }
269
- },
211
+ func: async ({ db }, { limit }) => ({ books: await db.listBooks(limit) }),
270
212
  })
271
213
 
272
214
  export const getBook = pikkuFunc({
273
215
  title: 'Get Book',
274
216
  description: 'Retrieve a book by ID',
275
- func: async ({ db }, { bookId }) => {
276
- return await db.getBook(bookId)
277
- },
217
+ func: async ({ db }, { bookId }) => await db.getBook(bookId),
278
218
  permissions: { user: isAuthenticated },
279
219
  })
280
220
 
281
- export const createBook = pikkuFunc({
282
- title: 'Create Book',
283
- func: async ({ db }, { title, author }) => {
284
- return await db.createBook({ title, author })
285
- },
286
- })
287
-
288
- export const deleteBook = pikkuFunc({
289
- title: 'Delete Book',
290
- func: async ({ db }, { bookId }) => {
291
- await db.deleteBook(bookId)
292
- return { deleted: true }
293
- },
294
- })
295
-
296
- // wirings/books.http.ts
297
- import { defineHTTPRoutes, wireHTTPRoutes } from '.pikku/pikku-types.gen.js'
221
+ // wirings/books.http.ts same defineHTTPRoutes/wireHTTPRoutes shape as the Route Groups example above
298
222
  import { addHTTPMiddleware } from '@pikku/core/http'
299
223
  import { cors, authBearer } from '@pikku/core/middleware'
300
224
 
301
- const booksRoutes = defineHTTPRoutes({
302
- tags: ['books'],
303
- routes: {
304
- list: { method: 'get', route: '/books', func: listBooks, auth: false },
305
- get: { method: 'get', route: '/books/:bookId', func: getBook },
306
- create: { method: 'post', route: '/books', func: createBook },
307
- delete: { method: 'delete', route: '/books/:bookId', func: deleteBook },
308
- },
309
- })
310
-
311
- wireHTTPRoutes({
312
- basePath: '/api',
313
- routes: { books: booksRoutes },
314
- })
315
-
316
225
  addHTTPMiddleware('*', [cors(), authBearer()])
317
226
  ```
@@ -0,0 +1,57 @@
1
+ # wireHTTP / defineHTTPRoutes / wireHTTPRoutes — full option reference
2
+
3
+ ## `wireHTTP(config)`
4
+
5
+ Wire a single function to an HTTP endpoint. Import from `@pikku/core/http`.
6
+
7
+ | Option | Type | Notes |
8
+ | --- | --- | --- |
9
+ | `method` | `'get' \| 'post' \| 'put' \| 'patch' \| 'delete' \| 'head'` | HTTP verb |
10
+ | `route` | `string` | e.g. `/books/:bookId` — `:params` become `data` fields |
11
+ | `func` | `PikkuFunc` | The function to call |
12
+ | `auth?` | `boolean` | Override default auth (`true` = require session) |
13
+ | `tags?` | `string[]` | For grouping, middleware targeting |
14
+ | `permissions?` | `Record<string, PikkuPermission \| PikkuPermission[]>` | Permission checks |
15
+ | `middleware?` | `PikkuMiddleware[]` | Per-route middleware |
16
+ | `sse?` | `boolean` | Enable Server-Sent Events |
17
+ | `contentType?` | `'xml' \| 'json'` | Response content type |
18
+ | `timeout?` | `number` | Request timeout in ms |
19
+ | `headers?` | `HTTPHeadersSchema` | Expected headers schema |
20
+ | `docs?` | `HTTPRouteDocsConfig` | OpenAPI docs config |
21
+
22
+ ## `defineHTTPRoutes(config)` + `wireHTTPRoutes(config)`
23
+
24
+ Group routes with shared configuration. Groups are composable and nestable. Import from `.pikku/pikku-types.gen.js`.
25
+
26
+ ```typescript
27
+ const routes = defineHTTPRoutes({
28
+ basePath?: string, // Prepended to all route paths
29
+ tags?: string[], // Applied to all routes in group
30
+ auth?: boolean, // Default auth for all routes (overridable per-route)
31
+ middleware?: PikkuMiddleware[],
32
+ routes: {
33
+ [key: string]: {
34
+ method: string,
35
+ route: string,
36
+ func: PikkuFunc,
37
+ auth?: boolean, // Override group auth
38
+ permissions?: Record<string, PikkuPermission | PikkuPermission[]>,
39
+ middleware?: PikkuMiddleware[],
40
+ }
41
+ }
42
+ })
43
+
44
+ wireHTTPRoutes({
45
+ basePath?: string, // Top-level prefix (e.g. '/api/v1')
46
+ middleware?: PikkuMiddleware[],
47
+ routes: {
48
+ [key: string]: ReturnType<typeof defineHTTPRoutes>,
49
+ }
50
+ })
51
+ ```
52
+
53
+ Config cascading rules:
54
+
55
+ - `basePath` — concatenates down the chain
56
+ - `tags` — merge (union)
57
+ - `auth` — child overrides parent