@bella-baxter/express 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 +68 -0
- package/dist/index.d.ts +43 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +48 -0
- package/dist/index.js.map +1 -0
- package/package.json +49 -0
package/README.md
ADDED
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
# @bella-baxter/express
|
|
2
|
+
|
|
3
|
+
[](https://www.npmjs.com/package/@bella-baxter/express)
|
|
4
|
+
[](LICENSE)
|
|
5
|
+
|
|
6
|
+
[Bella Baxter](https://github.com/Cosmic-Chimps/bella-baxter) middleware for Express.js — injects live-reloading secrets onto `req.bella`.
|
|
7
|
+
|
|
8
|
+
## Installation
|
|
9
|
+
|
|
10
|
+
```bash
|
|
11
|
+
npm install @bella-baxter/express express
|
|
12
|
+
# or
|
|
13
|
+
pnpm add @bella-baxter/express express
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
## Usage
|
|
17
|
+
|
|
18
|
+
```ts
|
|
19
|
+
import express from 'express';
|
|
20
|
+
import { createBellaMiddleware } from '@bella-baxter/express';
|
|
21
|
+
|
|
22
|
+
const app = express();
|
|
23
|
+
|
|
24
|
+
app.use(await createBellaMiddleware({
|
|
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', (req, res) => {
|
|
32
|
+
const dbUrl = req.bella.getOrThrow('DATABASE_URL');
|
|
33
|
+
res.json({ ok: true });
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
app.listen(3000);
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
## TypeScript — extend `req.bella`
|
|
40
|
+
|
|
41
|
+
```ts
|
|
42
|
+
// express.d.ts
|
|
43
|
+
import type { BellaConfig } from '@bella-baxter/express';
|
|
44
|
+
|
|
45
|
+
declare global {
|
|
46
|
+
namespace Express {
|
|
47
|
+
interface Request {
|
|
48
|
+
bella: BellaConfig;
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
## Environment variables
|
|
55
|
+
|
|
56
|
+
| Variable | Description |
|
|
57
|
+
|----------|-------------|
|
|
58
|
+
| `BELLA_BAXTER_URL` | Base URL of the Bella Baxter API |
|
|
59
|
+
| `BELLA_BAXTER_API_KEY` | API key (`bax-...`) |
|
|
60
|
+
| `BELLA_BAXTER_PROJECT` | Project slug |
|
|
61
|
+
| `BELLA_BAXTER_ENV` | Environment slug |
|
|
62
|
+
| `BELLA_BAXTER_PRIVATE_KEY` | Private key for ZKE (optional) |
|
|
63
|
+
|
|
64
|
+
## Links
|
|
65
|
+
|
|
66
|
+
- [GitHub](https://github.com/Cosmic-Chimps/bella-baxter)
|
|
67
|
+
- [Issues](https://github.com/Cosmic-Chimps/bella-baxter/issues)
|
|
68
|
+
- [Core SDK](https://www.npmjs.com/package/@bella-baxter/sdk)
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @bella-baxter/express
|
|
3
|
+
*
|
|
4
|
+
* Express middleware — injects bella secrets onto req.bella.
|
|
5
|
+
*
|
|
6
|
+
* @example
|
|
7
|
+
* ```ts
|
|
8
|
+
* import express from 'express';
|
|
9
|
+
* import { createBellaMiddleware } from '@bella-baxter/express';
|
|
10
|
+
*
|
|
11
|
+
* const app = express();
|
|
12
|
+
*
|
|
13
|
+
* app.use(await createBellaMiddleware({
|
|
14
|
+
* baxterUrl: process.env.BELLA_BAXTER_URL!,
|
|
15
|
+
* environmentSlug: 'production',
|
|
16
|
+
* apiKey: process.env.BELLA_BAXTER_API_KEY!,
|
|
17
|
+
*
|
|
18
|
+
* }));
|
|
19
|
+
*
|
|
20
|
+
* app.get('/health', (req, res) => {
|
|
21
|
+
* const dbUrl = req.bella.get('DATABASE_URL');
|
|
22
|
+
* res.json({ ok: true });
|
|
23
|
+
* });
|
|
24
|
+
* ```
|
|
25
|
+
*
|
|
26
|
+
* TypeScript: extend express Request to add req.bella:
|
|
27
|
+
* ```ts
|
|
28
|
+
* declare global {
|
|
29
|
+
* namespace Express {
|
|
30
|
+
* interface Request { bella: BellaConfig }
|
|
31
|
+
* }
|
|
32
|
+
* }
|
|
33
|
+
* ```
|
|
34
|
+
*/
|
|
35
|
+
import type { Request, Response, NextFunction } from 'express';
|
|
36
|
+
import { BellaConfig, type BellaConfigOptions } from '@bella-baxter/sdk';
|
|
37
|
+
export { BellaConfig, type BellaConfigOptions };
|
|
38
|
+
/**
|
|
39
|
+
* Creates an Express middleware that attaches a `BellaConfig` instance to `req.bella`.
|
|
40
|
+
* The config is loaded once and shared across all requests (polling runs in background).
|
|
41
|
+
*/
|
|
42
|
+
export declare function createBellaMiddleware(options: BellaConfigOptions): Promise<(req: Request, res: Response, next: NextFunction) => void>;
|
|
43
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiCG;AAEH,OAAO,KAAK,EAAE,OAAO,EAAE,QAAQ,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAC/D,OAAO,EAAE,WAAW,EAAqB,KAAK,kBAAkB,EAAE,MAAM,mBAAmB,CAAC;AAE5F,OAAO,EAAE,WAAW,EAAE,KAAK,kBAAkB,EAAE,CAAC;AAEhD;;;GAGG;AACH,wBAAsB,qBAAqB,CACzC,OAAO,EAAE,kBAAkB,GAC1B,OAAO,CAAC,CAAC,GAAG,EAAE,OAAO,EAAE,GAAG,EAAE,QAAQ,EAAE,IAAI,EAAE,YAAY,KAAK,IAAI,CAAC,CAOpE"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @bella-baxter/express
|
|
3
|
+
*
|
|
4
|
+
* Express middleware — injects bella secrets onto req.bella.
|
|
5
|
+
*
|
|
6
|
+
* @example
|
|
7
|
+
* ```ts
|
|
8
|
+
* import express from 'express';
|
|
9
|
+
* import { createBellaMiddleware } from '@bella-baxter/express';
|
|
10
|
+
*
|
|
11
|
+
* const app = express();
|
|
12
|
+
*
|
|
13
|
+
* app.use(await createBellaMiddleware({
|
|
14
|
+
* baxterUrl: process.env.BELLA_BAXTER_URL!,
|
|
15
|
+
* environmentSlug: 'production',
|
|
16
|
+
* apiKey: process.env.BELLA_BAXTER_API_KEY!,
|
|
17
|
+
*
|
|
18
|
+
* }));
|
|
19
|
+
*
|
|
20
|
+
* app.get('/health', (req, res) => {
|
|
21
|
+
* const dbUrl = req.bella.get('DATABASE_URL');
|
|
22
|
+
* res.json({ ok: true });
|
|
23
|
+
* });
|
|
24
|
+
* ```
|
|
25
|
+
*
|
|
26
|
+
* TypeScript: extend express Request to add req.bella:
|
|
27
|
+
* ```ts
|
|
28
|
+
* declare global {
|
|
29
|
+
* namespace Express {
|
|
30
|
+
* interface Request { bella: BellaConfig }
|
|
31
|
+
* }
|
|
32
|
+
* }
|
|
33
|
+
* ```
|
|
34
|
+
*/
|
|
35
|
+
import { BellaConfig, createBellaConfig } from '@bella-baxter/sdk';
|
|
36
|
+
export { BellaConfig };
|
|
37
|
+
/**
|
|
38
|
+
* Creates an Express middleware that attaches a `BellaConfig` instance to `req.bella`.
|
|
39
|
+
* The config is loaded once and shared across all requests (polling runs in background).
|
|
40
|
+
*/
|
|
41
|
+
export async function createBellaMiddleware(options) {
|
|
42
|
+
const bella = await createBellaConfig(options);
|
|
43
|
+
return (req, _res, next) => {
|
|
44
|
+
req.bella = bella;
|
|
45
|
+
next();
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiCG;AAGH,OAAO,EAAE,WAAW,EAAE,iBAAiB,EAA2B,MAAM,mBAAmB,CAAC;AAE5F,OAAO,EAAE,WAAW,EAA2B,CAAC;AAEhD;;;GAGG;AACH,MAAM,CAAC,KAAK,UAAU,qBAAqB,CACzC,OAA2B;IAE3B,MAAM,KAAK,GAAG,MAAM,iBAAiB,CAAC,OAAO,CAAC,CAAC;IAE/C,OAAO,CAAC,GAAsC,EAAE,IAAc,EAAE,IAAkB,EAAE,EAAE;QACpF,GAAG,CAAC,KAAK,GAAG,KAAK,CAAC;QAClB,IAAI,EAAE,CAAC;IACT,CAAC,CAAC;AACJ,CAAC"}
|
package/package.json
ADDED
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@bella-baxter/express",
|
|
3
|
+
"version": "0.1.1-preview.100",
|
|
4
|
+
"description": "Bella Baxter Express.js middleware — injects live-reloading secrets onto req.bella",
|
|
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
|
+
"express": ">=4"
|
|
23
|
+
},
|
|
24
|
+
"devDependencies": {
|
|
25
|
+
"typescript": "^6.0.2",
|
|
26
|
+
"@types/node": "^25.5.0",
|
|
27
|
+
"@types/express": "^5.0.6"
|
|
28
|
+
},
|
|
29
|
+
"keywords": [
|
|
30
|
+
"bella-baxter",
|
|
31
|
+
"secrets",
|
|
32
|
+
"express",
|
|
33
|
+
"middleware"
|
|
34
|
+
],
|
|
35
|
+
"license": "MIT",
|
|
36
|
+
"repository": {
|
|
37
|
+
"type": "git",
|
|
38
|
+
"url": "https://github.com/Cosmic-Chimps/bella-baxter-js.git",
|
|
39
|
+
"directory": "apps/sdk/js/packages/express"
|
|
40
|
+
},
|
|
41
|
+
"homepage": "https://github.com/Cosmic-Chimps/bella-baxter-js/tree/main/packages/express#readme",
|
|
42
|
+
"bugs": {
|
|
43
|
+
"url": "https://github.com/Cosmic-Chimps/bella-baxter-js/issues"
|
|
44
|
+
},
|
|
45
|
+
"scripts": {
|
|
46
|
+
"build": "tsc",
|
|
47
|
+
"typecheck": "tsc --noEmit"
|
|
48
|
+
}
|
|
49
|
+
}
|