@flaghoist/server 0.1.0 → 0.1.2

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.
Files changed (2) hide show
  1. package/README.md +58 -0
  2. package/package.json +22 -5
package/README.md ADDED
@@ -0,0 +1,58 @@
1
+ # @flaghoist/server
2
+
3
+ The Flaghoist server, as a function you call. It returns a [Hono](https://hono.dev) app, so it runs
4
+ on Cloudflare Workers, Node, Bun, Deno, or anywhere else Hono runs.
5
+
6
+ Most people never install this directly. The `flaghoist` CLI generates a Worker that uses it. Reach
7
+ for it when you want to compose the server yourself, add middleware, or plug in your own auth.
8
+
9
+ ```bash
10
+ npm install @flaghoist/server @flaghoist/adapter-cloudflare-kv
11
+ ```
12
+
13
+ ```ts
14
+ import { cloudflareKV } from '@flaghoist/adapter-cloudflare-kv'
15
+ import { apiKey, bearerToken, createFlagServer } from '@flaghoist/server'
16
+
17
+ export default createFlagServer((env) => ({
18
+ storage: cloudflareKV(env.FLAGS),
19
+ auth: {
20
+ admin: bearerToken(env.ADMIN_TOKEN),
21
+ read: apiKey(env.READ_API_KEY),
22
+ },
23
+ }))
24
+ ```
25
+
26
+ ## What it serves
27
+
28
+ - `POST /ofrep/v1/evaluate/flags` and `/flags/:key`, the OFREP read path, behind the read API key.
29
+ - `/api/v1/flags`, the admin CRUD API, behind admin auth, with an OpenAPI 3.1 document at
30
+ `/api/v1/openapi.json`.
31
+ - `/admin`, the dashboard, when you pass one.
32
+
33
+ ## The dashboard
34
+
35
+ The prebuilt admin UI ships in the same package, on its own entry point:
36
+
37
+ ```ts
38
+ import { dashboardHtml } from '@flaghoist/server/dashboard'
39
+
40
+ createFlagServer({ storage, auth, dashboard: dashboardHtml })
41
+ ```
42
+
43
+ It lives on a subpath rather than the package root, so a deploy that does not want the UI never
44
+ pulls the HTML into its bundle. It is a single self contained file with the fonts and styles
45
+ inlined, and it makes no requests to anything outside your server.
46
+
47
+ ## Auth
48
+
49
+ `bearerToken`, `apiKey` and `oidc` ship with it. Auth is an interface, so if none of those fit, pass
50
+ your own function.
51
+
52
+ ## Status
53
+
54
+ Pre-alpha, built and maintained by one person. The API can still change without notice, and
55
+ production use is not recommended yet. If you try it and something breaks, an issue is genuinely
56
+ useful.
57
+
58
+ Apache-2.0. Part of [Flaghoist](https://github.com/flaghoist/flaghoist).
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@flaghoist/server",
3
- "version": "0.1.0",
3
+ "version": "0.1.2",
4
4
  "description": "Hono app factory for Flaghoist: OFREP evaluate, admin CRUD, and pluggable auth.",
5
5
  "license": "Apache-2.0",
6
6
  "type": "module",
@@ -44,17 +44,34 @@
44
44
  "node": ">=20"
45
45
  },
46
46
  "dependencies": {
47
- "hono": "^4.13.0",
48
- "jose": "^6.2.8",
49
- "@flaghoist/core": "0.1.0"
47
+ "hono": "^4.13.3",
48
+ "jose": "^6.2.9",
49
+ "@flaghoist/core": "0.1.1"
50
50
  },
51
51
  "devDependencies": {
52
- "@flaghoist/adapter-memory": "0.1.0",
52
+ "@flaghoist/adapter-memory": "0.1.1",
53
53
  "@flaghoist/dashboard": "0.0.0"
54
54
  },
55
55
  "publishConfig": {
56
56
  "access": "public"
57
57
  },
58
+ "keywords": [
59
+ "feature-flags",
60
+ "openfeature",
61
+ "ofrep",
62
+ "hono",
63
+ "cloudflare-workers",
64
+ "self-hosted"
65
+ ],
66
+ "repository": {
67
+ "type": "git",
68
+ "url": "git+https://github.com/flaghoist/flaghoist.git",
69
+ "directory": "packages/server"
70
+ },
71
+ "homepage": "https://github.com/flaghoist/flaghoist#readme",
72
+ "bugs": {
73
+ "url": "https://github.com/flaghoist/flaghoist/issues"
74
+ },
58
75
  "scripts": {
59
76
  "build": "node scripts/embed-dashboard.mjs && tsup src/index.ts src/dashboard.ts --format esm,cjs --dts --clean",
60
77
  "test": "node scripts/embed-dashboard.mjs && vitest run --passWithNoTests",