@andrewcaires/api 5.4.0 → 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 +22 -1
- package/dist/index.cjs.js +2 -2
- package/dist/index.d.ts +80 -5
- package/dist/index.esm.js +2 -2
- package/package.json +9 -10
package/README.md
CHANGED
|
@@ -73,13 +73,34 @@ const main = async () => {
|
|
|
73
73
|
]
|
|
74
74
|
);
|
|
75
75
|
|
|
76
|
-
await app.
|
|
76
|
+
await app.run();
|
|
77
77
|
|
|
78
78
|
};
|
|
79
79
|
|
|
80
80
|
main().catch(console.log);
|
|
81
81
|
```
|
|
82
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
|
+
|
|
83
104
|
## MCP Streamable HTTP
|
|
84
105
|
|
|
85
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.
|