You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Cloud mode sends your metrics to the APIForge SaaS instead of storing them locally. The local SQLite database and the embedded dashboard are not started — everything is handled on the cloud side.
4
+
5
+
## When to use cloud mode
6
+
7
+
|| Local mode | Cloud mode |
8
+
|---|---|---|
9
+
| Setup | Zero config | Requires an API key |
10
+
| Data storage | SQLite on your server | APIForge SaaS |
1. The SDK intercepts each request and records route, method, status code, and latency in memory.
70
+
2. Every `flushInterval` milliseconds (default: 60s), the buffer is aggregated into per-route statistics and sent to `POST /ingest` on the SaaS API.
71
+
3. The SaaS stores the metrics in TimescaleDB and makes them available through the cloud dashboard.
72
+
73
+
## Circuit breaker
74
+
75
+
If the SaaS API is unreachable, the SDK automatically backs off:
76
+
77
+
- After **5 consecutive failures**, the transport pauses for **60 seconds**.
78
+
- During the pause, flush calls are silently skipped — your application is never blocked.
79
+
- After the pause, the SDK resumes sending normally.
80
+
81
+
A warning is printed to stdout when the circuit opens:
82
+
83
+
```
84
+
[apiforgejs] Cloud flush failures — pausing for 60s. Error: ...
85
+
[apiforgepy] Cloud flush failures — pausing for 60s. Error: ...
86
+
```
87
+
88
+
## Rotating an API key
89
+
90
+
If your API key is compromised, rotate it from the dashboard (`Project settings → Rotate key`). The old key is invalidated immediately. Update the environment variable and redeploy.
91
+
92
+
## Security
93
+
94
+
- API keys are stored as HMAC-SHA256 hashes server-side — the raw key is never persisted.
95
+
- All traffic between the SDK and the SaaS is encrypted over HTTPS.
96
+
- The SDK never reads request bodies, headers, cookies, or query parameter values regardless of mode.
Copy file name to clipboardExpand all lines: docs/guide/configuration.md
+60-26Lines changed: 60 additions & 26 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -2,16 +2,28 @@
2
2
3
3
## Node.js
4
4
5
-
All options are passed to the `apiforge()` factory. Every option is optional except `mode`.
5
+
All options are passed to the `apiforge()` factory. All options are optional — calling `apiforge()` with no arguments starts local mode with defaults.
6
6
7
7
```js
8
+
// Local mode (default)
8
9
app.use(apiforge({
9
-
mode:'local',
10
10
dbPath:'.apiforge.db',
11
11
dashboardPort:4242,
12
12
flushInterval:60_000,
13
13
env:'production',
14
-
release:'v1.4.0',
14
+
release:'v2.0.0',
15
+
service:'user-service',
16
+
sampling:1.0,
17
+
ignorePaths: ['/favicon.ico', '/health'],
18
+
}))
19
+
20
+
// Cloud mode
21
+
app.use(apiforge({
22
+
cloudUrl:'https://api.apiforge.fr',
23
+
apiKey:process.env.APIFORGE_API_KEY,
24
+
flushInterval:60_000,
25
+
env:'production',
26
+
release:'v2.0.0',
15
27
service:'user-service',
16
28
sampling:1.0,
17
29
ignorePaths: ['/favicon.ico', '/health'],
@@ -20,21 +32,32 @@ app.use(apiforge({
20
32
21
33
## Python
22
34
23
-
All options are passed to `ApiForgeMiddleware`. Every option is optional except `mode`.
35
+
All options are passed to `ApiForgeMiddleware`. All options are optional.
24
36
25
37
```python
38
+
# Local mode (default)
26
39
app.add_middleware(
27
40
ApiForgeMiddleware,
28
-
mode="local",
29
41
db_path=".apiforge.db",
30
42
dashboard_port=4242,
31
43
flush_interval=60_000, # ms
32
44
env="production",
33
-
release="v1.4.0",
45
+
release="v2.0.0",
34
46
service="user-service",
35
47
sampling=1.0,
36
48
ignore_paths=["/favicon.ico", "/health"],
37
49
)
50
+
51
+
# Cloud mode
52
+
app.add_middleware(
53
+
ApiForgeMiddleware,
54
+
cloud_url="https://api.apiforge.fr",
55
+
api_key=os.environ["APIFORGE_API_KEY"],
56
+
flush_interval=60_000,
57
+
env="production",
58
+
release="v2.0.0",
59
+
service="user-service",
60
+
)
38
61
```
39
62
40
63
::: tip Python naming
@@ -45,12 +68,25 @@ Python uses `snake_case` for option names. All other semantics — including uni
45
68
46
69
## Options
47
70
48
-
### `mode` / `mode`
71
+
### `cloudUrl` / `cloud_url`
72
+
73
+
-**Type:**`string | null`
74
+
-**Default:**`null`
75
+
76
+
Base URL of the APIForge SaaS API. Required for cloud mode, along with `apiKey`. When set, local SQLite storage and the embedded dashboard are disabled.
77
+
78
+
---
79
+
80
+
### `apiKey` / `api_key`
81
+
82
+
-**Type:**`string | null`
83
+
-**Default:**`null`
49
84
50
-
-**Type:**`'local'`
51
-
-**Required:** yes
85
+
Project API key, starting with `af_`. Generated from the APIForge dashboard when you create a project. Must be provided together with `cloudUrl`.
52
86
53
-
The storage and transport mode. Only `'local'` (SQLite) is available. SaaS mode is planned for a future version.
87
+
::: warning Keep your API key secret
88
+
Never commit your API key to source control. Use an environment variable: `process.env.APIFORGE_API_KEY` (Node.js) or `os.environ["APIFORGE_API_KEY"]` (Python).
89
+
:::
54
90
55
91
---
56
92
@@ -59,7 +95,7 @@ The storage and transport mode. Only `'local'` (SQLite) is available. SaaS mode
59
95
-**Type:**`string`
60
96
-**Default:**`'.apiforge.db'`
61
97
62
-
Path to the SQLite database file. Created automatically if it does not exist.
98
+
Path to the SQLite database file (local mode only). Created automatically if it does not exist.
63
99
64
100
---
65
101
@@ -68,18 +104,18 @@ Path to the SQLite database file. Created automatically if it does not exist.
68
104
-**Type:**`number` / `int`
69
105
-**Default:**`4242`
70
106
71
-
Port for the local dashboard HTTP server. Set to `0` to disable the dashboard entirely.
107
+
Port for the local dashboard HTTP server (local mode only). Set to `0` to disable the dashboard entirely.
72
108
73
109
```js
74
110
// Node.js
75
-
apiforge({ mode:'local', dashboardPort:0 }) // no dashboard
76
-
apiforge({ mode:'local', dashboardPort:9000 })// custom port
111
+
apiforge({ dashboardPort:0 }) // no dashboard
112
+
apiforge({ dashboardPort:9000 }) // custom port
77
113
```
78
114
79
115
```python
80
116
# Python
81
-
ApiForgeMiddleware(mode="local", dashboard_port=0) # no dashboard
82
-
ApiForgeMiddleware(mode="local", dashboard_port=9000) # custom port
117
+
ApiForgeMiddleware(dashboard_port=0) # no dashboard
118
+
ApiForgeMiddleware(dashboard_port=9000) # custom port
83
119
```
84
120
85
121
---
@@ -88,7 +124,7 @@ ApiForgeMiddleware(mode="local", dashboard_port=9000) # custom port
Copy file name to clipboardExpand all lines: docs/guide/dashboard.md
+7-3Lines changed: 7 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -2,6 +2,10 @@
2
2
3
3
The local dashboard is a built-in web UI served automatically by the SDK on port 4242 (configurable). It is identical across all SDKs — the same interface whether you run Node.js or Python.
4
4
5
+
::: info Cloud mode
6
+
In cloud mode, the local dashboard is not started. Metrics are visualized in the APIForge cloud dashboard instead. See [Cloud Mode](/guide/cloud-mode).
7
+
:::
8
+
5
9
```
6
10
http://localhost:4242
7
11
```
@@ -53,11 +57,11 @@ See [Automatic Insights](/features/insights).
0 commit comments