@bella-baxter/fastify 0.1.1-preview.100

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,63 @@
1
+ # @bella-baxter/fastify
2
+
3
+ [![npm](https://img.shields.io/npm/v/@bella-baxter/fastify)](https://www.npmjs.com/package/@bella-baxter/fastify)
4
+ [![license: MIT](https://img.shields.io/badge/license-MIT-blue.svg)](LICENSE)
5
+
6
+ [Bella Baxter](https://github.com/Cosmic-Chimps/bella-baxter) plugin for Fastify — decorates the Fastify instance with `app.bella` for live-reloading secrets.
7
+
8
+ ## Installation
9
+
10
+ ```bash
11
+ npm install @bella-baxter/fastify fastify
12
+ # or
13
+ pnpm add @bella-baxter/fastify fastify
14
+ ```
15
+
16
+ ## Usage
17
+
18
+ ```ts
19
+ import Fastify from 'fastify';
20
+ import { bellaPlugin } from '@bella-baxter/fastify';
21
+
22
+ const app = Fastify({ logger: true });
23
+
24
+ await app.register(bellaPlugin, {
25
+ baxterUrl: process.env.BELLA_BAXTER_URL!,
26
+ apiKey: process.env.BELLA_BAXTER_API_KEY!,
27
+ projectSlug: 'my-app', // or BELLA_BAXTER_PROJECT env var
28
+ environmentSlug: 'production', // or BELLA_BAXTER_ENV env var
29
+ });
30
+
31
+ app.get('/health', async () => {
32
+ const dbUrl = app.bella.getOrThrow('DATABASE_URL');
33
+ return { ok: true };
34
+ });
35
+
36
+ await app.listen({ port: 3000 });
37
+ ```
38
+
39
+ `app.bella` is typed as `BellaConfig & BellaSecrets` — after running `bella secrets generate typescript --declaration`, typed property access works automatically:
40
+
41
+ ```ts
42
+ app.bella.DATABASE_URL // string — typed!
43
+ ```
44
+
45
+ ## Lifecycle
46
+
47
+ The plugin hooks into `onClose` to call `bella.destroy()` — polling stops cleanly when Fastify shuts down.
48
+
49
+ ## Environment variables
50
+
51
+ | Variable | Description |
52
+ |----------|-------------|
53
+ | `BELLA_BAXTER_URL` | Base URL of the Bella Baxter API |
54
+ | `BELLA_BAXTER_API_KEY` | API key (`bax-...`) |
55
+ | `BELLA_BAXTER_PROJECT` | Project slug |
56
+ | `BELLA_BAXTER_ENV` | Environment slug |
57
+ | `BELLA_BAXTER_PRIVATE_KEY` | Private key for ZKE (optional) |
58
+
59
+ ## Links
60
+
61
+ - [GitHub](https://github.com/Cosmic-Chimps/bella-baxter)
62
+ - [Issues](https://github.com/Cosmic-Chimps/bella-baxter/issues)
63
+ - [Core SDK](https://www.npmjs.com/package/@bella-baxter/sdk)
@@ -0,0 +1,44 @@
1
+ /**
2
+ * @bella-baxter/fastify
3
+ *
4
+ * Fastify plugin — decorates the Fastify instance with a `bella` property
5
+ * containing a live-reloading BellaConfig instance.
6
+ *
7
+ * @example
8
+ * ```ts
9
+ * import Fastify from 'fastify';
10
+ * import { bellaPlugin } from '@bella-baxter/fastify';
11
+ *
12
+ * const app = Fastify();
13
+ *
14
+ * await app.register(bellaPlugin, {
15
+ * baxterUrl: process.env.BELLA_BAXTER_URL!,
16
+ * environmentSlug: 'production',
17
+ * apiKey: process.env.BELLA_BAXTER_API_KEY!,
18
+ *
19
+ * });
20
+ *
21
+ * app.get('/health', async (request, reply) => {
22
+ * const dbUrl = app.bella.getOrThrow('DATABASE_URL');
23
+ * return { ok: true };
24
+ * });
25
+ *
26
+ * await app.listen({ port: 3000 });
27
+ * ```
28
+ *
29
+ * TypeScript: Fastify augments the type automatically via the plugin declaration.
30
+ */
31
+ import type { FastifyPluginAsync } from 'fastify';
32
+ import { BellaConfig, BellaSecrets, type BellaConfigOptions } from '@bella-baxter/sdk';
33
+ export { BellaConfig, type BellaConfigOptions };
34
+ declare module 'fastify' {
35
+ interface FastifyInstance {
36
+ bella: BellaConfig & BellaSecrets;
37
+ }
38
+ }
39
+ /**
40
+ * Fastify plugin that decorates the Fastify instance with `bella`.
41
+ * Uses `fastify-plugin` to avoid plugin scope isolation (bella is accessible from all routes).
42
+ */
43
+ export declare const bellaPlugin: FastifyPluginAsync<BellaConfigOptions>;
44
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AAGH,OAAO,KAAK,EAAmB,kBAAkB,EAAE,MAAM,SAAS,CAAC;AACnE,OAAO,EAAE,WAAW,EAAE,YAAY,EAAqB,KAAK,kBAAkB,EAAE,MAAM,mBAAmB,CAAC;AAE1G,OAAO,EAAE,WAAW,EAAE,KAAK,kBAAkB,EAAE,CAAC;AAEhD,OAAO,QAAQ,SAAS,CAAC;IACvB,UAAU,eAAe;QACvB,KAAK,EAAE,WAAW,GAAG,YAAY,CAAC;KACnC;CACF;AAgBD;;;GAGG;AACH,eAAO,MAAM,WAAW,wCAGtB,CAAC"}
package/dist/index.js ADDED
@@ -0,0 +1,50 @@
1
+ /**
2
+ * @bella-baxter/fastify
3
+ *
4
+ * Fastify plugin — decorates the Fastify instance with a `bella` property
5
+ * containing a live-reloading BellaConfig instance.
6
+ *
7
+ * @example
8
+ * ```ts
9
+ * import Fastify from 'fastify';
10
+ * import { bellaPlugin } from '@bella-baxter/fastify';
11
+ *
12
+ * const app = Fastify();
13
+ *
14
+ * await app.register(bellaPlugin, {
15
+ * baxterUrl: process.env.BELLA_BAXTER_URL!,
16
+ * environmentSlug: 'production',
17
+ * apiKey: process.env.BELLA_BAXTER_API_KEY!,
18
+ *
19
+ * });
20
+ *
21
+ * app.get('/health', async (request, reply) => {
22
+ * const dbUrl = app.bella.getOrThrow('DATABASE_URL');
23
+ * return { ok: true };
24
+ * });
25
+ *
26
+ * await app.listen({ port: 3000 });
27
+ * ```
28
+ *
29
+ * TypeScript: Fastify augments the type automatically via the plugin declaration.
30
+ */
31
+ import fp from 'fastify-plugin';
32
+ import { BellaConfig, createBellaConfig } from '@bella-baxter/sdk';
33
+ export { BellaConfig };
34
+ const bellaPluginImpl = async (fastify, options) => {
35
+ const bella = await createBellaConfig(options);
36
+ fastify.decorate('bella', bella);
37
+ fastify.addHook('onClose', (_instance, done) => {
38
+ bella.destroy();
39
+ done();
40
+ });
41
+ };
42
+ /**
43
+ * Fastify plugin that decorates the Fastify instance with `bella`.
44
+ * Uses `fastify-plugin` to avoid plugin scope isolation (bella is accessible from all routes).
45
+ */
46
+ export const bellaPlugin = fp(bellaPluginImpl, {
47
+ fastify: '>=4',
48
+ name: 'bella-baxter',
49
+ });
50
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AAEH,OAAO,EAAE,MAAM,gBAAgB,CAAC;AAEhC,OAAO,EAAE,WAAW,EAAgB,iBAAiB,EAA2B,MAAM,mBAAmB,CAAC;AAE1G,OAAO,EAAE,WAAW,EAA2B,CAAC;AAQhD,MAAM,eAAe,GAA2C,KAAK,EACnE,OAAwB,EACxB,OAA2B,EAC3B,EAAE;IACF,MAAM,KAAK,GAAG,MAAM,iBAAiB,CAAC,OAAO,CAAC,CAAC;IAE/C,OAAO,CAAC,QAAQ,CAAC,OAAO,EAAE,KAAK,CAAC,CAAC;IAEjC,OAAO,CAAC,OAAO,CAAC,SAAS,EAAE,CAAC,SAAS,EAAE,IAAI,EAAE,EAAE;QAC7C,KAAK,CAAC,OAAO,EAAE,CAAC;QAChB,IAAI,EAAE,CAAC;IACT,CAAC,CAAC,CAAC;AACL,CAAC,CAAC;AAEF;;;GAGG;AACH,MAAM,CAAC,MAAM,WAAW,GAAG,EAAE,CAAC,eAAe,EAAE;IAC7C,OAAO,EAAE,KAAK;IACd,IAAI,EAAE,cAAc;CACrB,CAAC,CAAC"}
package/package.json ADDED
@@ -0,0 +1,51 @@
1
+ {
2
+ "name": "@bella-baxter/fastify",
3
+ "version": "0.1.1-preview.100",
4
+ "description": "Bella Baxter Fastify plugin — decorates the Fastify instance with live-reloading secrets",
5
+ "type": "module",
6
+ "main": "./dist/index.js",
7
+ "types": "./dist/index.d.ts",
8
+ "exports": {
9
+ ".": {
10
+ "import": "./dist/index.js",
11
+ "types": "./dist/index.d.ts"
12
+ }
13
+ },
14
+ "files": [
15
+ "README.md",
16
+ "dist"
17
+ ],
18
+ "dependencies": {
19
+ "@bella-baxter/sdk": "0.1.1-preview.100"
20
+ },
21
+ "peerDependencies": {
22
+ "fastify": ">=4",
23
+ "fastify-plugin": ">=4"
24
+ },
25
+ "devDependencies": {
26
+ "typescript": "^5.9.3",
27
+ "@types/node": "^25.5.0",
28
+ "fastify": "^5.8.3",
29
+ "fastify-plugin": "^5.1.0"
30
+ },
31
+ "keywords": [
32
+ "bella-baxter",
33
+ "secrets",
34
+ "fastify",
35
+ "plugin"
36
+ ],
37
+ "license": "MIT",
38
+ "repository": {
39
+ "type": "git",
40
+ "url": "https://github.com/Cosmic-Chimps/bella-baxter-js.git",
41
+ "directory": "apps/sdk/js/packages/fastify"
42
+ },
43
+ "homepage": "https://github.com/Cosmic-Chimps/bella-baxter-js/tree/main/packages/fastify#readme",
44
+ "bugs": {
45
+ "url": "https://github.com/Cosmic-Chimps/bella-baxter-js/issues"
46
+ },
47
+ "scripts": {
48
+ "build": "tsc",
49
+ "typecheck": "tsc --noEmit"
50
+ }
51
+ }