@pikku/skills 0.12.22 → 0.12.26

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 (106) hide show
  1. package/CHANGELOG.md +134 -0
  2. package/dist/skills.gen.js +1 -1
  3. package/package.json +1 -1
  4. package/skills/pikku-a11y/SKILL.md +59 -0
  5. package/skills/pikku-addon/SKILL.md +2 -2
  6. package/skills/pikku-agent/SKILL.md +67 -316
  7. package/skills/pikku-agent/references/agents.md +299 -0
  8. package/skills/{pikku-ai-vercel/SKILL.md → pikku-agent/references/runner-vercel.md} +2 -24
  9. package/skills/{pikku-ai-voice/SKILL.md → pikku-agent/references/voice.md} +1 -22
  10. package/skills/pikku-architect/SKILL.md +265 -0
  11. package/skills/pikku-auth/SKILL.md +89 -0
  12. package/skills/{pikku-better-auth/SKILL.md → pikku-auth/references/better-auth.md} +126 -34
  13. package/skills/{pikku-jose/SKILL.md → pikku-auth/references/jose.md} +1 -23
  14. package/skills/{pikku-machine-auth/SKILL.md → pikku-auth/references/machine-auth.md} +0 -23
  15. package/skills/pikku-auth/references/permissions.md +261 -0
  16. package/skills/{pikku-security/SKILL.md → pikku-auth/references/sessions.md} +0 -20
  17. package/skills/pikku-build/SKILL.md +88 -0
  18. package/skills/{pikku-build-app/SKILL.md → pikku-build/references/app.md} +76 -24
  19. package/skills/{pikku-feature/SKILL.md → pikku-build/references/feature.md} +1 -8
  20. package/skills/{pikku-build-app → pikku-build}/references/multi-app.md +56 -1
  21. package/skills/{pikku-build-platform/SKILL.md → pikku-build/references/platform.md} +22 -37
  22. package/skills/{pikku-template-clone/SKILL.md → pikku-build/references/post-clone.md} +0 -6
  23. package/skills/{pikku-build-quick/SKILL.md → pikku-build/references/quick.md} +4 -20
  24. package/skills/{pikku-build-app → pikku-build}/references/ship.md +9 -3
  25. package/skills/pikku-concepts/SKILL.md +72 -7
  26. package/skills/pikku-concepts/references/concept-mapping.md +8 -8
  27. package/skills/pikku-deploy/SKILL.md +158 -0
  28. package/skills/{pikku-deploy-azure/SKILL.md → pikku-deploy/references/azure.md} +18 -50
  29. package/skills/pikku-deploy/references/cloudflare.md +104 -0
  30. package/skills/pikku-deploy/references/express.md +92 -0
  31. package/skills/{pikku-deploy-fastify/SKILL.md → pikku-deploy/references/fastify.md} +8 -32
  32. package/skills/{pikku-deploy-lambda/SKILL.md → pikku-deploy/references/lambda.md} +6 -27
  33. package/skills/{pikku-deploy-nextjs/SKILL.md → pikku-deploy/references/nextjs.md} +9 -33
  34. package/skills/pikku-deploy/references/uws.md +72 -0
  35. package/skills/pikku-deploy/references/ws.md +75 -0
  36. package/skills/pikku-emails/SKILL.md +3 -2
  37. package/skills/pikku-fabric/SKILL.md +47 -20
  38. package/skills/{pikku-fabric-debug/SKILL.md → pikku-fabric/references/debugging.md} +0 -6
  39. package/skills/pikku-i18n/SKILL.md +62 -207
  40. package/skills/{pikku-paraglide/SKILL.md → pikku-i18n/references/enum-labels.md} +0 -6
  41. package/skills/pikku-i18n/references/messages.md +218 -0
  42. package/skills/{pikku-rtl/SKILL.md → pikku-i18n/references/rtl.md} +3 -9
  43. package/skills/pikku-knowledge/SKILL.md +15 -0
  44. package/skills/pikku-kysely/SKILL.md +13 -13
  45. package/skills/pikku-list-query/SKILL.md +163 -0
  46. package/skills/pikku-meta/SKILL.md +58 -130
  47. package/skills/{pikku-deps/SKILL.md → pikku-meta/references/audit.md} +1 -17
  48. package/skills/pikku-meta/references/meta.md +114 -0
  49. package/skills/{pikku-versioning/SKILL.md → pikku-meta/references/versioning.md} +0 -26
  50. package/skills/pikku-middleware/SKILL.md +5 -5
  51. package/skills/pikku-n8n-import/SKILL.md +0 -1
  52. package/skills/pikku-permissions/SKILL.md +75 -229
  53. package/skills/pikku-react/SKILL.md +50 -298
  54. package/skills/pikku-react/references/client.md +313 -0
  55. package/skills/{pikku-react-query/SKILL.md → pikku-react/references/react-query.md} +2 -22
  56. package/skills/{pikku-workflows-client/SKILL.md → pikku-react/references/workflows.md} +1 -22
  57. package/skills/pikku-realtime/SKILL.md +110 -251
  58. package/skills/pikku-scenario/SKILL.md +60 -45
  59. package/skills/pikku-scenario/references/persona-run.md +148 -0
  60. package/skills/pikku-seo/SKILL.md +133 -0
  61. package/skills/pikku-service-backends/SKILL.md +154 -0
  62. package/skills/pikku-service-backends/references/aws.md +106 -0
  63. package/skills/pikku-service-backends/references/backblaze.md +57 -0
  64. package/skills/pikku-service-backends/references/mongodb.md +90 -0
  65. package/skills/pikku-service-backends/references/redis.md +75 -0
  66. package/skills/pikku-service-backends/references/schema.md +63 -0
  67. package/skills/pikku-services/SKILL.md +68 -291
  68. package/skills/{pikku-audit/SKILL.md → pikku-services/references/audit.md} +0 -22
  69. package/skills/{pikku-config/SKILL.md → pikku-services/references/config.md} +1 -25
  70. package/skills/{pikku-pino/SKILL.md → pikku-services/references/pino.md} +0 -20
  71. package/skills/pikku-services/references/services.md +272 -0
  72. package/skills/pikku-software-archaeology/README.md +5 -1
  73. package/skills/pikku-software-archaeology/SKILL.md +16 -2
  74. package/skills/{pikku-product-second-opinion/example/sample-report.md → pikku-software-archaeology/example/second-opinion-sample-report.md} +1 -1
  75. package/skills/pikku-software-archaeology/references/blueprint.schema.json +1 -1
  76. package/skills/pikku-software-archaeology/references/pikku-mapping.md +3 -3
  77. package/skills/{pikku-product-second-opinion/SKILL.md → pikku-software-archaeology/references/second-opinion.md} +4 -9
  78. package/skills/pikku-webhook/SKILL.md +224 -0
  79. package/skills/pikku-wiring/SKILL.md +180 -0
  80. package/skills/{pikku-websocket/SKILL.md → pikku-wiring/references/channel.md} +2 -35
  81. package/skills/{pikku-cli/SKILL.md → pikku-wiring/references/cli.md} +1 -33
  82. package/skills/{pikku-gateway-slack/SKILL.md → pikku-wiring/references/gateway-slack.md} +0 -23
  83. package/skills/{pikku-http/SKILL.md → pikku-wiring/references/http.md} +3 -39
  84. package/skills/{pikku-mcp/SKILL.md → pikku-wiring/references/mcp.md} +0 -33
  85. package/skills/{pikku-queue/SKILL.md → pikku-wiring/references/queue.md} +1 -33
  86. package/skills/pikku-wiring/references/realtime.md +265 -0
  87. package/skills/{pikku-rpc/SKILL.md → pikku-wiring/references/rpc.md} +0 -32
  88. package/skills/{pikku-schedule/SKILL.md → pikku-wiring/references/scheduler.md} +1 -35
  89. package/skills/{pikku-trigger/SKILL.md → pikku-wiring/references/trigger.md} +0 -43
  90. package/skills/pikku-workflow/SKILL.md +39 -2
  91. package/skills/pikku-aws/SKILL.md +0 -161
  92. package/skills/pikku-backblaze/SKILL.md +0 -104
  93. package/skills/pikku-deploy-cloudflare/SKILL.md +0 -123
  94. package/skills/pikku-deploy-express/SKILL.md +0 -122
  95. package/skills/pikku-deploy-uws/SKILL.md +0 -144
  96. package/skills/pikku-mongodb/SKILL.md +0 -113
  97. package/skills/pikku-product-second-opinion/README.md +0 -43
  98. package/skills/pikku-redis/SKILL.md +0 -99
  99. package/skills/pikku-schema-ajv/SKILL.md +0 -83
  100. package/skills/pikku-schema-cfworker/SKILL.md +0 -82
  101. package/skills/pikku-ws/SKILL.md +0 -87
  102. /package/skills/{pikku-build-app → pikku-build}/references/theming.md +0 -0
  103. /package/skills/{pikku-product-second-opinion/references/report-template.md → pikku-software-archaeology/references/second-opinion-report-template.md} +0 -0
  104. /package/skills/{pikku-cli/references/complete-example.md → pikku-wiring/references/cli-complete-example.md} +0 -0
  105. /package/skills/{pikku-http → pikku-wiring}/references/http-options.md +0 -0
  106. /package/skills/{pikku-realtime/references/other-routes.md → pikku-wiring/references/realtime-other-routes.md} +0 -0
@@ -1,99 +0,0 @@
1
- ---
2
- name: pikku-redis
3
- description: >-
4
- Use when setting up Redis-backed services in a Pikku app. Covers channel stores, workflow
5
- services, secret services, event hubs, agent runs, and deployment services backed by Redis.
6
- TRIGGER when: code uses RedisChannelStore, RedisWorkflowService, RedisSecretService, or user
7
- asks about Redis setup with Pikku. DO NOT TRIGGER when: user asks about BullMQ queues (use
8
- pikku-queue) or SQL databases (use pikku-kysely).
9
- ---
10
-
11
- # Pikku Redis
12
-
13
- ## Agent Operating Procedure
14
-
15
- Use this skill as an execution checklist, not reference material.
16
-
17
- 1. Discover before editing. Run the relevant `pikku meta ... --json` command and inspect only the focused output you need.
18
- 2. Identify the source files that own the behavior. Do not start by reading generated output, `.pikku`, `node_modules`, vendored packages, or broad build artifacts.
19
- 3. Make the smallest source change that satisfies the task. Keep generated files generated, and avoid hand-editing SDKs, schema output, or typegen.
20
- 4. Validate with the narrowest relevant command first, then run `pikku-verify` or `pikku all` when functions, wirings, schemas, or generated clients may have changed.
21
- 5. If validation fails, fix the source cause and rerun validation. Do not paper over generated errors by editing generated files.
22
-
23
- `@pikku/redis` provides Redis-backed implementations of Pikku's core service interfaces using [ioredis](https://github.com/redis/ioredis).
24
-
25
- ## Installation
26
-
27
- ```bash
28
- yarn add @pikku/redis
29
- ```
30
-
31
- ## API Reference
32
-
33
- ### Available Services
34
-
35
- All services accept a Redis connection (ioredis `Redis` instance, `RedisOptions`, or connection string) in their constructor.
36
-
37
- | Service | Interface | Purpose |
38
- | ------------------------- | ---------------------- | ---------------------------------------------- |
39
- | `RedisChannelStore` | `ChannelStore` | WebSocket channel state persistence |
40
- | `RedisEventHubStore` | `EventHubStore` | Event hub state persistence |
41
- | `RedisWorkflowService` | `PikkuWorkflowService` | Workflow definition storage |
42
- | `RedisWorkflowRunService` | `WorkflowRunService` | Workflow execution tracking |
43
- | `RedisDeploymentService` | `DeploymentService` | Deployment state management |
44
- | `RedisAgentRunService` | `AgentRunService` | Agent execution tracking |
45
- | `RedisSecretService` | `SecretService` | Encrypted secret storage (envelope encryption) |
46
- | `RedisSessionStore` | `SessionStore` | Persisted user sessions |
47
-
48
- ### Secret Service
49
-
50
- Envelope encryption: `key` derives the KEK that wraps each secret's own DEK.
51
- Keeping `previousKey` set is what makes `rotateKEK()` possible — it re-wraps
52
- every secret onto the current key and returns the new version.
53
-
54
- ```typescript
55
- import { RedisSecretService } from '@pikku/redis'
56
-
57
- const secrets = new RedisSecretService(
58
- connectionOrConfig: Redis | RedisOptions | string,
59
- config: {
60
- key: string // the KEK passphrase
61
- keyVersion?: number // defaults to 1
62
- previousKey?: string // required to rotate
63
- keyPrefix?: string // namespaces the redis keys
64
- }
65
- )
66
-
67
- await secrets.getSecret<T = string>(key: string): Promise<T>
68
- await secrets.getSecrets<T>(keys: (keyof T & string)[]): Promise<Partial<T>>
69
- await secrets.hasSecret(key: string): Promise<boolean>
70
- await secrets.setSecret(key: string, value: unknown): Promise<void>
71
- await secrets.deleteSecret(key: string): Promise<void>
72
- await secrets.rotateKEK(): Promise<number>
73
- await secrets.close(): Promise<void>
74
- ```
75
-
76
- ## Usage Patterns
77
-
78
- ### Full Setup
79
-
80
- ```typescript
81
- import {
82
- RedisChannelStore,
83
- RedisWorkflowService,
84
- RedisSecretService,
85
- } from '@pikku/redis'
86
-
87
- const createSingletonServices = pikkuServices(async (config) => {
88
- const logger = new PinoLogger()
89
-
90
- const channelStore = new RedisChannelStore(config.redisUrl)
91
- const workflowService = new RedisWorkflowService(config.redisUrl)
92
-
93
- const secrets = new RedisSecretService(config.redisUrl, {
94
- key: config.kekPassphrase,
95
- })
96
-
97
- return { config, logger, channelStore, workflowService, secrets }
98
- })
99
- ```
@@ -1,83 +0,0 @@
1
- ---
2
- name: pikku-schema-ajv
3
- description: >-
4
- Use when setting up JSON schema validation with AJV in a Pikku app. Covers AjvSchemaService for
5
- request/response validation. TRIGGER when: code uses AjvSchemaService, user asks about AJV, JSON
6
- schema validation, or @pikku/schema-ajv. DO NOT TRIGGER when: user asks about Cloudflare Workers
7
- schema validation (use pikku-schema-cfworker).
8
- ---
9
-
10
- # Pikku Schema AJV (JSON Schema Validation)
11
-
12
- ## Agent Operating Procedure
13
-
14
- Use this skill as an execution checklist, not reference material.
15
-
16
- 1. Discover before editing. Run the relevant `pikku meta ... --json` command and inspect only the focused output you need.
17
- 2. Identify the source files that own the behavior. Do not start by reading generated output, `.pikku`, `node_modules`, vendored packages, or broad build artifacts.
18
- 3. Make the smallest source change that satisfies the task. Keep generated files generated, and avoid hand-editing SDKs, schema output, or typegen.
19
- 4. Validate with the narrowest relevant command first, then run `pikku-verify` or `pikku all` when functions, wirings, schemas, or generated clients may have changed.
20
- 5. If validation fails, fix the source cause and rerun validation. Do not paper over generated errors by editing generated files.
21
-
22
- `@pikku/schema-ajv` provides JSON schema validation using [AJV](https://ajv.js.org/). Implements the `SchemaService` interface from `@pikku/core`. This is the default schema validator for Node.js environments.
23
-
24
- ## Installation
25
-
26
- ```bash
27
- yarn add @pikku/schema-ajv
28
- ```
29
-
30
- ## API Reference
31
-
32
- ### `AjvSchemaService`
33
-
34
- ```typescript
35
- import { AjvSchemaService } from '@pikku/schema-ajv'
36
-
37
- const schema = new AjvSchemaService(logger: Logger)
38
- ```
39
-
40
- **Methods:**
41
-
42
- - `compileSchema(name: string, schema: any): void` — Compile and register a JSON schema under `name`
43
- - `validateSchema(schemaName: string, json: any): void` — Validate data against a compiled schema (throws on failure)
44
- - `getSchemaNames(): Set<string>` — Get all registered schema names
45
- - `getSchemaKeys(schemaName: string): string[]` — Top-level property keys, or `[]` if the schema has no `properties`
46
-
47
- The first argument is the **name**, the second the schema — the parameter is
48
- called `schema` in the source, which reads backwards.
49
-
50
- ### Behaviour that matters
51
-
52
- - **Registration is name-keyed and never re-compiles.** A second
53
- `compileSchema('X', …)` with a different schema is a no-op; the first one wins
54
- for the process lifetime. `@pikku/schema-cfworker` _does_ recompile on a
55
- changed value, so a dev hot-reload after codegen picks up a changed schema
56
- there but not here — restart the process instead.
57
- - **AJV is a module-level singleton**, shared by every `AjvSchemaService` you
58
- construct, so compiled schema names are global to the process.
59
- - **`useDefaults: true` mutates the validated object**, filling in schema
60
- defaults in place. `coerceTypes: false`, so a query-string `"1"` will not
61
- become `1` — the wiring layer is what coerces, not this service.
62
- - `ajv-formats` is registered, so `format` keywords (`email`, `uuid`, `date-time`)
63
- are enforced.
64
- - A failed validation throws `UnprocessableContentError` (a 422). A _missing_
65
- schema throws a bare string, `Missing validator for <name>` — not an `Error`,
66
- so `catch (e) { e.message }` reads `undefined`. That normally means codegen
67
- didn't run.
68
-
69
- ## Usage Patterns
70
-
71
- ### With Pikku Services
72
-
73
- ```typescript
74
- import { AjvSchemaService } from '@pikku/schema-ajv'
75
-
76
- const createSingletonServices = pikkuServices(async (config) => {
77
- const logger = new ConsoleLogger()
78
- const schema = new AjvSchemaService(logger)
79
- return { config, logger, schema }
80
- })
81
- ```
82
-
83
- Pikku automatically uses the schema service to validate function inputs and outputs when schemas are defined in your function definitions.
@@ -1,82 +0,0 @@
1
- ---
2
- name: pikku-schema-cfworker
3
- description: >-
4
- Use when setting up JSON schema validation for Cloudflare Workers in a Pikku app. Covers
5
- CFWorkerSchemaService as a lightweight alternative to AJV. TRIGGER when: code uses
6
- CFWorkerSchemaService, user asks about schema validation on Cloudflare Workers, or
7
- @pikku/schema-cfworker. DO NOT TRIGGER when: user asks about AJV schema validation (use
8
- pikku-schema-ajv).
9
- ---
10
-
11
- # Pikku Schema CFWorker (Cloudflare Workers Validation)
12
-
13
- ## Agent Operating Procedure
14
-
15
- Use this skill as an execution checklist, not reference material.
16
-
17
- 1. Discover before editing. Run the relevant `pikku meta ... --json` command and inspect only the focused output you need.
18
- 2. Identify the source files that own the behavior. Do not start by reading generated output, `.pikku`, `node_modules`, vendored packages, or broad build artifacts.
19
- 3. Make the smallest source change that satisfies the task. Keep generated files generated, and avoid hand-editing SDKs, schema output, or typegen.
20
- 4. Validate with the narrowest relevant command first, then run `pikku-verify` or `pikku all` when functions, wirings, schemas, or generated clients may have changed.
21
- 5. If validation fails, fix the source cause and rerun validation. Do not paper over generated errors by editing generated files.
22
-
23
- `@pikku/schema-cfworker` provides JSON schema validation using [@cfworker/json-schema](https://github.com/cfworker/cfworker), a lightweight validator compatible with Cloudflare Workers (no `eval` or `new Function`). Implements the `SchemaService` interface from `@pikku/core`.
24
-
25
- ## Installation
26
-
27
- ```bash
28
- yarn add @pikku/schema-cfworker
29
- ```
30
-
31
- ## API Reference
32
-
33
- ### `CFWorkerSchemaService`
34
-
35
- ```typescript
36
- import { CFWorkerSchemaService } from '@pikku/schema-cfworker'
37
-
38
- const schema = new CFWorkerSchemaService(logger: Logger)
39
- ```
40
-
41
- **Methods:**
42
-
43
- - `compileSchema(name: string, schema: any): void` — Compile and register a JSON schema under `name`
44
- - `validateSchema(schemaName: string, json: any): void` — Validate data against a compiled schema (throws on failure)
45
- - `getSchemaNames(): Set<string>` — Get all registered schema names
46
- - `getSchemaKeys(schemaName: string): string[]` — Top-level property keys, or `[]` if the schema has no `properties`
47
-
48
- ### Where it differs from AJV
49
-
50
- These two are not drop-in equivalents, and the differences are the kind that
51
- surface as behaviour changes rather than compile errors:
52
-
53
- - **No `useDefaults`.** AJV fills schema defaults into the validated object in
54
- place; this validator does not. A field you relied on being defaulted arrives
55
- `undefined` on Workers.
56
- - **It re-compiles when the schema value changes.** AJV caches by name forever;
57
- here a `compileSchema` with a different value for the same name replaces the
58
- validator, which is what lets a dev hot-reload pick up regenerated schemas.
59
- - **Each validator gets a deep clone of the schema** (`@cfworker/json-schema`
60
- mutates what it is given, which throws on a frozen generated object).
61
- - A compile failure throws `Error('Failed to compile schema: <name>')` with the
62
- underlying cause swallowed — check the schema by hand when you see it.
63
-
64
- A failed validation throws `UnprocessableContentError` (422) with the validator
65
- errors joined; a _missing_ schema throws a bare string, `Missing validator for
66
- <name>`, not an `Error`.
67
-
68
- ## Usage Patterns
69
-
70
- ### With Cloudflare Workers
71
-
72
- ```typescript
73
- import { CFWorkerSchemaService } from '@pikku/schema-cfworker'
74
-
75
- const createSingletonServices = pikkuServices(async (config) => {
76
- const logger = new ConsoleLogger()
77
- const schema = new CFWorkerSchemaService(logger)
78
- return { config, logger, schema }
79
- })
80
- ```
81
-
82
- Use this instead of `@pikku/schema-ajv` when deploying to Cloudflare Workers, as AJV uses `eval` which is not permitted in the Workers runtime.
@@ -1,87 +0,0 @@
1
- ---
2
- name: pikku-ws
3
- description: >-
4
- Use when setting up a WebSocket server with the ws library in a Pikku app. Covers the ws runtime
5
- adapter for Pikku channels. TRIGGER when: code uses @pikku/ws, user asks about ws library
6
- WebSocket server, or Node.js WebSocket runtime. DO NOT TRIGGER when: user asks about WebSocket
7
- wiring/channels (use pikku-websocket) or uWebSockets (use pikku-deploy-uws).
8
- installGroups: [fabric]
9
- ---
10
-
11
- # Pikku WS (WebSocket Server Runtime)
12
-
13
- ## Agent Operating Procedure
14
-
15
- Use this skill as an execution checklist, not reference material.
16
-
17
- 1. Discover before editing. Run the relevant `pikku meta ... --json` command and inspect only the focused output you need.
18
- 2. Identify the source files that own the behavior. Do not start by reading generated output, `.pikku`, `node_modules`, vendored packages, or broad build artifacts.
19
- 3. Make the smallest source change that satisfies the task. Keep generated files generated, and avoid hand-editing SDKs, schema output, or typegen.
20
- 4. Validate with the narrowest relevant command first, then run `pikku-verify` or `pikku all` when functions, wirings, schemas, or generated clients may have changed.
21
- 5. If validation fails, fix the source cause and rerun validation. Do not paper over generated errors by editing generated files.
22
-
23
- `@pikku/ws` provides a WebSocket server runtime using the [ws](https://github.com/websockets/ws) library, connecting Pikku's channel system to a Node.js WebSocket server.
24
-
25
- ## Installation
26
-
27
- ```bash
28
- yarn add @pikku/ws ws
29
- ```
30
-
31
- ## Usage Patterns
32
-
33
- ### Basic Setup
34
-
35
- The package exports one function, `pikkuWebsocketHandler` — there is no server
36
- class. You own the `http.Server` and the `WebSocketServer`; the handler attaches
37
- the upgrade and message plumbing to them.
38
-
39
- ```typescript
40
- import { DEFAULT_WS_MAX_PAYLOAD, pikkuWebsocketHandler } from '@pikku/ws'
41
- import { stopSingletonServices } from '@pikku/core'
42
- import { Server } from 'http'
43
- import { WebSocketServer } from 'ws'
44
-
45
- import '../.pikku/pikku-bootstrap.gen.js'
46
- import { createConfig, createSingletonServices } from './services.js'
47
-
48
- const config = await createConfig()
49
- const singletonServices = await createSingletonServices(config)
50
-
51
- const server = new Server()
52
- const wss = new WebSocketServer({
53
- noServer: true,
54
- maxPayload: DEFAULT_WS_MAX_PAYLOAD,
55
- })
56
-
57
- pikkuWebsocketHandler({
58
- server,
59
- wss,
60
- logger: singletonServices.logger,
61
- logRoutes: true, // print the wired channels at startup
62
- loadSchemas: true, // compile input schemas up front
63
- })
64
-
65
- server.listen(4002, 'localhost')
66
- ```
67
-
68
- `noServer: true` is not optional decoration — the handler performs the upgrade
69
- itself so it can run pikku's HTTP middleware chain (auth, cors) against the
70
- upgrade request before a channel exists. Letting `ws` bind the server directly
71
- would skip that.
72
-
73
- Services come from the bootstrap import and the global singleton registry, which
74
- is why nothing is passed in. The event hub is taken from
75
- `singletonServices.eventHub` when it is a `LocalEventHubService`, and a local one
76
- is created otherwise — so a single-process app gets pub/sub for free, while a
77
- multi-instance deployment must register a distributed hub (see `pikku-realtime`).
78
-
79
- The options type also extends `RunHTTPWiringOptions`, so per-request settings
80
- such as `respondWith404`, `coerceDataFromSchema` and `bubbleErrors` are accepted
81
- here too.
82
-
83
- On shutdown, call `stopSingletonServices()` then close `wss` and `server`.
84
-
85
- See `pikku-websocket` for channel wiring details, and
86
- `pikku-deploy-fastify`/`pikku-deploy-express` when the WebSocket server shares a
87
- port with an HTTP app.