@adhd/apigen-plugin-api-express 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 +20 -0
- package/index.d.ts +2 -0
- package/index.js +31725 -0
- package/index.mjs +425209 -0
- package/lib/generate.d.ts +5 -0
- package/lib/plugin.d.ts +4 -0
- package/lib/run.d.ts +3 -0
- package/package.json +16 -0
package/README.md
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
# @adhd/apigen-plugin-api-express
|
|
2
|
+
|
|
3
|
+
apigen target plugin (`--type api-express`) — exposes a source file's exports as an
|
|
4
|
+
**Express HTTP API**. One `POST /<namespace>/<fn>` route per export (handlers call
|
|
5
|
+
`res.json(result)`). Generates `routes.ts` 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-express --namespace api --opt port=3000
|
|
13
|
+
apigen generate --source ./api.ts --type api-express --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