@adhd/apigen-plugin-api-fastify 0.1.0

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 ADDED
@@ -0,0 +1,20 @@
1
+ # @adhd/apigen-plugin-api-fastify
2
+
3
+ apigen target plugin (`--type api-fastify`) — exposes a source file's exports as a
4
+ **Fastify HTTP API**. One `POST /<namespace>/<fn>` route per export. Generates `routes.ts`
5
+ to disk *and* runs a live server.
6
+
7
+ Part of [apigen](../../README.md). Driven via [`@adhd/apigen-cli`](../../cli).
8
+
9
+ ```bash
10
+ alias apigen='npx tsx packages/apigen/cli/src/index.ts'
11
+
12
+ apigen run --source ./api.ts --type api-fastify --namespace api --opt port=3000
13
+ apigen generate --source ./api.ts --type api-fastify --out-dir ./out # → out/routes.ts
14
+
15
+ curl -X POST http://127.0.0.1:3000/api/getUser \
16
+ -H 'content-type: application/json' -d '{"data":{"userId":"abc"}}'
17
+ ```
18
+
19
+ `--opt` keys: `port` (`3000`), `host` (`127.0.0.1`), `routePrefix` (`""`). Method must be
20
+ uppercase `POST`; arguments are wrapped in `{"data":{…}}` (the request envelope).
package/index.d.ts ADDED
@@ -0,0 +1,4 @@
1
+ export { apiFastifyPlugin } from './lib/plugin';
2
+ export { default } from './lib/plugin';
3
+ export { generate } from './lib/generate';
4
+ export { run } from './lib/run';