@andrewcaires/api 5.3.6 → 5.4.1

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/README.md CHANGED
@@ -37,10 +37,6 @@ TOKEN_COOKIE_SET=true
37
37
  TOKEN_HEADER=authorization
38
38
  TOKEN_TYPE=bearer
39
39
 
40
- KEY_HEADER=x-api-key
41
- KEY_PREFIX=api
42
- KEY_PEPPER=change-me-to-a-long-random-pepper
43
-
44
40
  API_WEBSOCKET_START=false
45
41
  ```
46
42
 
@@ -77,13 +73,34 @@ const main = async () => {
77
73
  ]
78
74
  );
79
75
 
80
- await app.listen();
76
+ await app.run();
81
77
 
82
78
  };
83
79
 
84
80
  main().catch(console.log);
85
81
  ```
86
82
 
83
+ ## Workers
84
+
85
+ Use `@Worker` em um metodo de controller carregado pela aplicação e inicie o processo com `app.run()`. Sem `--worker`, `app.run()` inicia a API normalmente; com `--worker`, ele prepara banco, migrations e `sync()` dos controllers, executa o worker e nao abre a porta HTTP.
86
+
87
+ ```ts
88
+ import { BaseController, Worker } from "@andrewcaires/api";
89
+
90
+ class ReportsController extends BaseController {
91
+
92
+ @Worker("reports.daily")
93
+ protected async daily() {
94
+
95
+ return { ok: true };
96
+ }
97
+ }
98
+ ```
99
+
100
+ ```sh
101
+ node dist/index.js --worker reports.daily
102
+ ```
103
+
87
104
  ## MCP Streamable HTTP
88
105
 
89
106
  `McpController` exposes `/mcp` for MCP Streamable HTTP using protocol `2025-11-25` by default. Clients must call `initialize`, send `notifications/initialized`, and then include `MCP-Session-Id` and `MCP-Protocol-Version` on subsequent requests. The server also keeps compatibility with `2025-06-18` when that version is requested during initialization.