@onetype/stack-api-kit 1.0.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 +58 -0
- package/dist/api-BZrn0c9T.d.ts +654 -0
- package/dist/chunk-UCWOCNTI.js +1749 -0
- package/dist/chunk-UCWOCNTI.js.map +1 -0
- package/dist/index.d.ts +327 -0
- package/dist/index.js +381 -0
- package/dist/index.js.map +1 -0
- package/dist/testing.d.ts +165 -0
- package/dist/testing.js +450 -0
- package/dist/testing.js.map +1 -0
- package/package.json +75 -0
package/README.md
ADDED
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
# stack-api-kit
|
|
2
|
+
|
|
3
|
+
One package a Stack API is built on. A kernel that holds the seams, and the
|
|
4
|
+
plugins we ship behind it.
|
|
5
|
+
|
|
6
|
+
This is a library. It carries no routes, no tables and no features: what the
|
|
7
|
+
API is, the API writes.
|
|
8
|
+
|
|
9
|
+
## Install
|
|
10
|
+
|
|
11
|
+
```sh
|
|
12
|
+
npm install @onetype/stack-api-kit better-sqlite3 drizzle-orm hono zod
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
Those four are peers, so a project holds one copy of each and the kit holds
|
|
16
|
+
none.
|
|
17
|
+
|
|
18
|
+
## Use
|
|
19
|
+
|
|
20
|
+
```ts
|
|
21
|
+
import { discover, start } from "@onetype/stack-api-kit";
|
|
22
|
+
|
|
23
|
+
const api = await start({
|
|
24
|
+
plugins: discover(import.meta.glob("./plugins/*/plugin.ts")),
|
|
25
|
+
database: { file: "./data/app.db" },
|
|
26
|
+
identify: (kernel) => (c) => Sessions.of(kernel, c.req.header("cookie")),
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
export default { fetch: api.fetch, port: 3000 };
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
`identify` is given the started kernel, so it may ask a plugin who this is.
|
|
33
|
+
|
|
34
|
+
`start` opens the database, migrates in dependency order, validates every
|
|
35
|
+
contract, and either starts every plugin or throws naming the one that failed.
|
|
36
|
+
|
|
37
|
+
Two entries: `.` is everything, `./testing` the checks a project runs on
|
|
38
|
+
itself.
|
|
39
|
+
|
|
40
|
+
A plugin declares everything crossing its boundary: dependencies, tables,
|
|
41
|
+
routes, events, hooks, config, and the hosts it may call. What is not declared
|
|
42
|
+
does not exist, and the kernel refuses it before anything starts.
|
|
43
|
+
|
|
44
|
+
## Work on it
|
|
45
|
+
|
|
46
|
+
`#docs/architecture.md` is the map, `#docs/procedures/` the rules, and each
|
|
47
|
+
plugin's `usage.md` its contract. That is the whole context needed for one
|
|
48
|
+
plugin.
|
|
49
|
+
|
|
50
|
+
```sh
|
|
51
|
+
tools/check.sh
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
Runs what CI runs: types, tests, the 1800-character limit, and the plugin
|
|
55
|
+
boundaries.
|
|
56
|
+
|
|
57
|
+
Every check here was broken on purpose and watched to fail. One never seen red
|
|
58
|
+
proves only that it runs.
|