@adjedaini/clockwork-node 0.0.1
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/LICENSE +21 -0
- package/README.md +225 -0
- package/dist/globals.d.ts +27 -0
- package/dist/index.d.ts +61 -0
- package/dist/index.js +695 -0
- package/dist/public/assets/index-B2HEyS_P.css +1 -0
- package/dist/public/assets/index-B83PrqXa.css +1 -0
- package/dist/public/assets/index-CdsiP1dN.css +1 -0
- package/dist/public/assets/index-Df9idoqY.js +198 -0
- package/dist/public/assets/index-KmGT-iQM.js +198 -0
- package/dist/public/assets/index-znhjCgo1.js +198 -0
- package/dist/public/index.html +13 -0
- package/node_modules/@adjedaini/clockwork-core/dist/index.d.ts +53 -0
- package/node_modules/@adjedaini/clockwork-core/dist/index.js +192 -0
- package/node_modules/@adjedaini/clockwork-core/package.json +17 -0
- package/node_modules/@adjedaini/clockwork-core/src/index.ts +194 -0
- package/node_modules/@adjedaini/clockwork-core/src/ring-buffer.ts +47 -0
- package/node_modules/@adjedaini/clockwork-core/tsconfig.build.json +6 -0
- package/node_modules/@adjedaini/clockwork-core/tsconfig.json +10 -0
- package/node_modules/@adjedaini/clockwork-core/tsup.config.ts +13 -0
- package/node_modules/@adjedaini/clockwork-db-interceptor/dist/index.d.ts +33 -0
- package/node_modules/@adjedaini/clockwork-db-interceptor/dist/index.js +163 -0
- package/node_modules/@adjedaini/clockwork-db-interceptor/package.json +18 -0
- package/node_modules/@adjedaini/clockwork-db-interceptor/src/index.ts +28 -0
- package/node_modules/@adjedaini/clockwork-db-interceptor/src/mysql2.ts +84 -0
- package/node_modules/@adjedaini/clockwork-db-interceptor/src/pg.ts +56 -0
- package/node_modules/@adjedaini/clockwork-db-interceptor/tsconfig.build.json +6 -0
- package/node_modules/@adjedaini/clockwork-db-interceptor/tsconfig.json +10 -0
- package/node_modules/@adjedaini/clockwork-db-interceptor/tsup.config.ts +13 -0
- package/node_modules/@adjedaini/clockwork-log-interceptor/dist/index.d.ts +25 -0
- package/node_modules/@adjedaini/clockwork-log-interceptor/dist/index.js +153 -0
- package/node_modules/@adjedaini/clockwork-log-interceptor/package.json +16 -0
- package/node_modules/@adjedaini/clockwork-log-interceptor/src/index.ts +14 -0
- package/node_modules/@adjedaini/clockwork-log-interceptor/src/pino.ts +78 -0
- package/node_modules/@adjedaini/clockwork-log-interceptor/src/winston.ts +66 -0
- package/node_modules/@adjedaini/clockwork-log-interceptor/tsconfig.build.json +4 -0
- package/node_modules/@adjedaini/clockwork-log-interceptor/tsconfig.json +10 -0
- package/node_modules/@adjedaini/clockwork-log-interceptor/tsup.config.ts +13 -0
- package/node_modules/@adjedaini/clockwork-plugins/dist/index.d.ts +45 -0
- package/node_modules/@adjedaini/clockwork-plugins/dist/index.js +172 -0
- package/node_modules/@adjedaini/clockwork-plugins/package.json +19 -0
- package/node_modules/@adjedaini/clockwork-plugins/src/console.ts +70 -0
- package/node_modules/@adjedaini/clockwork-plugins/src/context.ts +30 -0
- package/node_modules/@adjedaini/clockwork-plugins/src/index.ts +50 -0
- package/node_modules/@adjedaini/clockwork-plugins/src/process-errors.ts +33 -0
- package/node_modules/@adjedaini/clockwork-plugins/tsconfig.build.json +1 -0
- package/node_modules/@adjedaini/clockwork-plugins/tsconfig.json +16 -0
- package/node_modules/@adjedaini/clockwork-plugins/tsup.config.ts +13 -0
- package/node_modules/@adjedaini/clockwork-shared/dist/index.d.ts +97 -0
- package/node_modules/@adjedaini/clockwork-shared/dist/index.js +18 -0
- package/node_modules/@adjedaini/clockwork-shared/package.json +14 -0
- package/node_modules/@adjedaini/clockwork-shared/src/index.ts +96 -0
- package/node_modules/@adjedaini/clockwork-shared/tsconfig.build.json +6 -0
- package/node_modules/@adjedaini/clockwork-shared/tsconfig.json +9 -0
- package/node_modules/@adjedaini/clockwork-shared/tsup.config.ts +13 -0
- package/node_modules/@adjedaini/clockwork-transport-http/dist/index.d.ts +75 -0
- package/node_modules/@adjedaini/clockwork-transport-http/dist/index.js +306 -0
- package/node_modules/@adjedaini/clockwork-transport-http/package.json +18 -0
- package/node_modules/@adjedaini/clockwork-transport-http/src/index.ts +277 -0
- package/node_modules/@adjedaini/clockwork-transport-http/src/sanitize.ts +92 -0
- package/node_modules/@adjedaini/clockwork-transport-http/src/types.ts +37 -0
- package/node_modules/@adjedaini/clockwork-transport-http/tsconfig.build.json +6 -0
- package/node_modules/@adjedaini/clockwork-transport-http/tsconfig.json +10 -0
- package/node_modules/@adjedaini/clockwork-transport-http/tsup.config.ts +13 -0
- package/package.json +69 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 a.djedaini
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,225 @@
|
|
|
1
|
+
# @adjedaini/clockwork-node
|
|
2
|
+
|
|
3
|
+
Framework-agnostic debugging, profiling, and metrics for Node.js. One middleware: API + optional UI + request capture. **Automatic capture** (opt-out): `console.*`, uncaught errors, and optionally pg/mysql2 queries are correlated to the current request via AsyncLocalStorage.
|
|
4
|
+
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
## Install
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
npm install @adjedaini/clockwork-node
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
## Use
|
|
14
|
+
|
|
15
|
+
### Express
|
|
16
|
+
|
|
17
|
+
```javascript
|
|
18
|
+
import express from 'express';
|
|
19
|
+
import { startClockwork } from '@adjedaini/clockwork-node';
|
|
20
|
+
|
|
21
|
+
const clockwork = startClockwork({
|
|
22
|
+
path: '/__clockwork',
|
|
23
|
+
ui: true,
|
|
24
|
+
autoConsole: true,
|
|
25
|
+
autoErrors: true,
|
|
26
|
+
captureRequestBody: true,
|
|
27
|
+
captureResponseBody: true,
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
const app = express();
|
|
31
|
+
app.use(express.json());
|
|
32
|
+
app.use(clockwork.middleware);
|
|
33
|
+
|
|
34
|
+
app.get('/api/hello', (req, res) => {
|
|
35
|
+
console.log('Processing hello');
|
|
36
|
+
res.json({ message: 'Hello' });
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
app.listen(3000);
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
### Fastify
|
|
43
|
+
|
|
44
|
+
```javascript
|
|
45
|
+
import Fastify from 'fastify';
|
|
46
|
+
import { startClockwork } from '@adjedaini/clockwork-node';
|
|
47
|
+
|
|
48
|
+
const clockwork = startClockwork({ path: '/__clockwork', ui: true });
|
|
49
|
+
const app = Fastify();
|
|
50
|
+
|
|
51
|
+
app.addHook('preHandler', (req, reply, done) => {
|
|
52
|
+
clockwork.middleware(
|
|
53
|
+
{ method: req.method, url: req.url, originalUrl: req.url, path: req.routerPath, headers: req.headers, body: req.body, query: req.query },
|
|
54
|
+
{ setHeader: reply.header.bind(reply), get status() { return reply; }, statusCode: reply.statusCode, on: reply.raw.on.bind(reply.raw), end: (b) => reply.raw.end(b), send: reply.send.bind(reply), json: reply.send.bind(reply) },
|
|
55
|
+
done
|
|
56
|
+
);
|
|
57
|
+
});
|
|
58
|
+
|
|
59
|
+
app.get('/api/hello', (req, reply) => {
|
|
60
|
+
const id = req.raw.clockworkId;
|
|
61
|
+
if (id) clockwork.core.captureLog(id, 'info', 'Hello');
|
|
62
|
+
return reply.send({ message: 'Hello' });
|
|
63
|
+
});
|
|
64
|
+
|
|
65
|
+
app.listen({ port: 3000 });
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
### Node.js `http`
|
|
69
|
+
|
|
70
|
+
```javascript
|
|
71
|
+
import { createServer } from 'http';
|
|
72
|
+
import { startClockwork } from '@adjedaini/clockwork-node';
|
|
73
|
+
|
|
74
|
+
const clockwork = startClockwork({ path: '/__clockwork', ui: true });
|
|
75
|
+
|
|
76
|
+
const server = createServer((req, res) => {
|
|
77
|
+
const reqLike = {
|
|
78
|
+
method: req.method ?? 'GET',
|
|
79
|
+
url: req.url,
|
|
80
|
+
originalUrl: req.url,
|
|
81
|
+
path: req.url?.split('?')[0],
|
|
82
|
+
headers: req.headers,
|
|
83
|
+
};
|
|
84
|
+
const resLike = {
|
|
85
|
+
setHeader: res.setHeader.bind(res),
|
|
86
|
+
get statusCode() { return res.statusCode; },
|
|
87
|
+
set statusCode(v) { res.statusCode = v; },
|
|
88
|
+
status(code) { res.statusCode = code; return resLike; },
|
|
89
|
+
on: res.on.bind(res),
|
|
90
|
+
end: res.end.bind(res),
|
|
91
|
+
send: (b) => { res.setHeader('Content-Type', 'application/json'); res.end(typeof b === 'string' ? b : JSON.stringify(b)); },
|
|
92
|
+
json: (b) => { res.setHeader('Content-Type', 'application/json'); res.end(JSON.stringify(b)); },
|
|
93
|
+
};
|
|
94
|
+
clockwork.middleware(reqLike, resLike, () => {
|
|
95
|
+
if (req.url?.startsWith('/api/')) {
|
|
96
|
+
const id = req.clockworkId;
|
|
97
|
+
if (id) clockwork.core.captureLog(id, 'info', 'Request');
|
|
98
|
+
res.setHeader('Content-Type', 'application/json');
|
|
99
|
+
res.end(JSON.stringify({ message: 'Hello' }));
|
|
100
|
+
} else {
|
|
101
|
+
res.statusCode = 404;
|
|
102
|
+
res.end('Not found');
|
|
103
|
+
}
|
|
104
|
+
});
|
|
105
|
+
});
|
|
106
|
+
|
|
107
|
+
server.listen(3000);
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
Open **http://localhost:3000/__clockwork/app**. UI is at `{path}/app`, API at `{path}`.
|
|
111
|
+
|
|
112
|
+
---
|
|
113
|
+
|
|
114
|
+
## TypeScript
|
|
115
|
+
|
|
116
|
+
For typed `req.clockworkId` (Express / Node), add to your `tsconfig.json` or a `.d.ts` file:
|
|
117
|
+
|
|
118
|
+
```json
|
|
119
|
+
{ "compilerOptions": { "types": ["@adjedaini/clockwork-node/globals"] } }
|
|
120
|
+
```
|
|
121
|
+
|
|
122
|
+
Or in a `.d.ts` file:
|
|
123
|
+
|
|
124
|
+
```ts
|
|
125
|
+
/// <reference types="@adjedaini/clockwork-node/globals" />
|
|
126
|
+
```
|
|
127
|
+
|
|
128
|
+
---
|
|
129
|
+
|
|
130
|
+
## Options
|
|
131
|
+
|
|
132
|
+
| Option | Default | Description |
|
|
133
|
+
|--------|---------|-------------|
|
|
134
|
+
| `path` | `'/__clockwork'` | Base path for API and UI. UI is served at `{path}/app`. |
|
|
135
|
+
| `ui` | `true` | Enable built-in dashboard at `{path}/app`. |
|
|
136
|
+
| `uiPath` | (package dist) | Override UI directory. |
|
|
137
|
+
| `plugins` | — | Full plugin set. When set, autoConsole/autoErrors/autoDb/dbPlugins/autoLogPlugins are ignored. |
|
|
138
|
+
| `autoConsole` | `true` | Intercept `console.*` (used when `plugins` not set). |
|
|
139
|
+
| `autoErrors` | `true` | Capture uncaughtException / unhandledRejection (used when `plugins` not set). |
|
|
140
|
+
| `autoLogPlugins` | `false` | Intercept pino/winston when installed (used when `plugins` not set). |
|
|
141
|
+
| `autoDb` | `false` | Enable default DB plugins pg + mysql2 (used when `plugins` not set). |
|
|
142
|
+
| `dbPlugins` | — | DB plugins when not using full `plugins` (e.g. `[pgPlugin]`). |
|
|
143
|
+
| `captureRequestBody` | `true` | Capture request body. |
|
|
144
|
+
| `captureResponseBody` | `true` | Capture response body. |
|
|
145
|
+
| `ignoreStartsWith` | `[]` | Skip paths that start with these. |
|
|
146
|
+
| `core.maxRequests` | `100` | Ring buffer size. |
|
|
147
|
+
| `core.storage` | (ring buffer) | Custom storage implementing `IRequestStorage`. |
|
|
148
|
+
|
|
149
|
+
The instance has **registerPlugin(plugin)** to plug in any plugin at runtime, and **restore()** to undo all patches (e.g. for tests or shutdown).
|
|
150
|
+
|
|
151
|
+
### Generic plugin system
|
|
152
|
+
|
|
153
|
+
All interception is done via **plugins** implementing `ClockworkPlugin`: `{ name: string, install(ctx: IPluginContext) => () => void }`. Context provides `ctx.core` and `ctx.getRequestId()`.
|
|
154
|
+
|
|
155
|
+
- **Context plugin** (`contextPlugin`) — provides AsyncLocalStorage and request correlation. Must run first when using defaults.
|
|
156
|
+
- **Console plugin** (`consolePlugin`) — intercepts `console.*` (native log).
|
|
157
|
+
- **Process errors plugin** (`processErrorsPlugin`) — captures uncaughtException / unhandledRejection.
|
|
158
|
+
- **Log plugins** (`pinoPlugin`, `winstonPlugin`) — intercept pino/winston when installed. Enable with `autoLogPlugins: true` or add to `plugins`.
|
|
159
|
+
- **DB plugins** (`pgPlugin`, `mysql2Plugin`) — intercept pg/mysql2 queries. Enable with `autoDb: true` or `dbPlugins: [pgPlugin]`.
|
|
160
|
+
|
|
161
|
+
Use the **full plugin list** or the **default builder**:
|
|
162
|
+
|
|
163
|
+
```javascript
|
|
164
|
+
import {
|
|
165
|
+
startClockwork,
|
|
166
|
+
contextPlugin,
|
|
167
|
+
consolePlugin,
|
|
168
|
+
processErrorsPlugin,
|
|
169
|
+
pinoPlugin,
|
|
170
|
+
winstonPlugin,
|
|
171
|
+
pgPlugin,
|
|
172
|
+
mysql2Plugin,
|
|
173
|
+
getDefaultPlugins,
|
|
174
|
+
} from '@adjedaini/clockwork-node';
|
|
175
|
+
|
|
176
|
+
// Option 1: defaults (context + console + processErrors; optional DB / log libs)
|
|
177
|
+
const clockwork = startClockwork({
|
|
178
|
+
autoConsole: true,
|
|
179
|
+
autoErrors: true,
|
|
180
|
+
autoLogPlugins: true,
|
|
181
|
+
autoDb: true,
|
|
182
|
+
});
|
|
183
|
+
|
|
184
|
+
// Option 2: custom plugin set (you must include contextPlugin first for request correlation)
|
|
185
|
+
const clockwork = startClockwork({
|
|
186
|
+
plugins: [
|
|
187
|
+
contextPlugin,
|
|
188
|
+
consolePlugin,
|
|
189
|
+
processErrorsPlugin,
|
|
190
|
+
pinoPlugin,
|
|
191
|
+
pgPlugin,
|
|
192
|
+
],
|
|
193
|
+
});
|
|
194
|
+
|
|
195
|
+
// Option 3: build defaults then add more
|
|
196
|
+
const plugins = getDefaultPlugins({
|
|
197
|
+
console: true,
|
|
198
|
+
errors: true,
|
|
199
|
+
logPlugins: true,
|
|
200
|
+
db: true,
|
|
201
|
+
dbPlugins: [pgPlugin],
|
|
202
|
+
});
|
|
203
|
+
const clockwork = startClockwork({ plugins });
|
|
204
|
+
|
|
205
|
+
// Option 4: plug in at runtime
|
|
206
|
+
const clockwork = startClockwork();
|
|
207
|
+
clockwork.registerPlugin(pinoPlugin);
|
|
208
|
+
clockwork.registerPlugin(pgPlugin);
|
|
209
|
+
```
|
|
210
|
+
|
|
211
|
+
**API:** `GET {path}`, `GET {path}/:id`, `GET {path}/latest`, `GET {path}/metrics`.
|
|
212
|
+
|
|
213
|
+
**Build output:** The published package has `dist/index.js`, `dist/index.d.ts`, and `dist/public/` (index.html + assets). Serve `dist/public` at `{path}/app` or rely on the built-in middleware.
|
|
214
|
+
|
|
215
|
+
---
|
|
216
|
+
|
|
217
|
+
- **Build:** `npm run build` → packages → UI → root bundle → copy UI to `dist/public`.
|
|
218
|
+
- **Packages:** Plugins live under `packages/`: `clockwork-plugins` (context, console, process-errors, getDefaultPlugins), `clockwork-log-interceptor` (pino, winston), `clockwork-db-interceptor` (pg, mysql2). Root depends on `clockwork-plugins`, which aggregates the others.
|
|
219
|
+
- **Scripts:** `build`, `dev:example`, `dev:ui`, `test`, `clean`, `version` (changesets), `release`.
|
|
220
|
+
|
|
221
|
+
---
|
|
222
|
+
|
|
223
|
+
## License
|
|
224
|
+
|
|
225
|
+
MIT
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Global type augmentation for Clockwork request id.
|
|
3
|
+
* Reference this file for typed req.clockworkId in Express / Node.
|
|
4
|
+
*
|
|
5
|
+
* Usage: add to your tsconfig.json "include" or a .d.ts file:
|
|
6
|
+
* /// <reference types="@adjedaini/clockwork-node/globals" />
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
import type { IncomingMessage } from 'http';
|
|
10
|
+
|
|
11
|
+
declare global {
|
|
12
|
+
namespace Express {
|
|
13
|
+
interface Request {
|
|
14
|
+
/** Set by Clockwork middleware. Use with clockwork.core.captureLog(id, ...). */
|
|
15
|
+
clockworkId?: string;
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
declare module 'http' {
|
|
21
|
+
interface IncomingMessage {
|
|
22
|
+
/** Set by Clockwork middleware when using Node http.createServer. */
|
|
23
|
+
clockworkId?: string;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export {};
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import { MonitorCore, ClockworkPlugin, CoreConfig } from '@adjedaini/clockwork-core';
|
|
2
|
+
export { ClockworkPlugin, CoreConfig, IPluginContext, MonitorCore } from '@adjedaini/clockwork-core';
|
|
3
|
+
import { ClockworkRequestLike, ClockworkResponseLike, NextLike, createHttpAdapter, HttpAdapterOptions } from '@adjedaini/clockwork-transport-http';
|
|
4
|
+
export { ClockworkRequestLike, ClockworkResponseLike, HttpAdapterOptions } from '@adjedaini/clockwork-transport-http';
|
|
5
|
+
import { getDefaultPlugins } from '@adjedaini/clockwork-plugins';
|
|
6
|
+
export { ContextPluginContext, consolePlugin, contextPlugin, defaultCorePlugins, defaultDbPlugins, defaultLogPlugins, getDefaultPlugins, mysql2Plugin, pgPlugin, pinoPlugin, processErrorsPlugin, winstonPlugin } from '@adjedaini/clockwork-plugins';
|
|
7
|
+
export { ClockworkContext } from '@adjedaini/clockwork-shared';
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* @adjedaini/clockwork-node
|
|
11
|
+
* Public API: startClockwork(options) -> { core, middleware, handler, uiPath, registerPlugin, restore }
|
|
12
|
+
*/
|
|
13
|
+
|
|
14
|
+
interface StartClockworkOptions extends HttpAdapterOptions {
|
|
15
|
+
/** Core config (e.g. maxRequests). */
|
|
16
|
+
core?: CoreConfig;
|
|
17
|
+
/** Enable built-in UI at path + /app. Default true. */
|
|
18
|
+
ui?: boolean;
|
|
19
|
+
/** Override UI directory (default: package dist/public). */
|
|
20
|
+
uiPath?: string;
|
|
21
|
+
/** Full plugin set. When set, options below (autoConsole, autoErrors, autoDb, dbPlugins, autoLogPlugins) are ignored. */
|
|
22
|
+
plugins?: ClockworkPlugin[];
|
|
23
|
+
/** Intercept console.* and attach to current request. Default true. (Used when plugins not set.) */
|
|
24
|
+
autoConsole?: boolean;
|
|
25
|
+
/** Capture uncaughtException / unhandledRejection. Default true. (Used when plugins not set.) */
|
|
26
|
+
autoErrors?: boolean;
|
|
27
|
+
/** Intercept pino/winston when installed. Default false. (Used when plugins not set.) */
|
|
28
|
+
autoLogPlugins?: boolean;
|
|
29
|
+
/** Enable default DB plugins (pg, mysql2). Default false. (Used when plugins not set.) */
|
|
30
|
+
autoDb?: boolean;
|
|
31
|
+
/** DB plugins when autoDb or plugins not set. When set with autoDb, only these DB plugins are used. */
|
|
32
|
+
dbPlugins?: ClockworkPlugin[];
|
|
33
|
+
}
|
|
34
|
+
interface ClockworkInstance {
|
|
35
|
+
core: MonitorCore;
|
|
36
|
+
middleware: (req: ClockworkRequestLike, res: ClockworkResponseLike, next: NextLike) => void;
|
|
37
|
+
handler: ReturnType<typeof createHttpAdapter>['dataHandler'];
|
|
38
|
+
uiPath: string;
|
|
39
|
+
/** Register any plugin (context, console, DB, log libs). Restore is tracked on instance.restore(). */
|
|
40
|
+
registerPlugin: (plugin: ClockworkPlugin) => void;
|
|
41
|
+
restore: () => void;
|
|
42
|
+
}
|
|
43
|
+
declare function startClockwork(options?: StartClockworkOptions): ClockworkInstance;
|
|
44
|
+
declare const _default: {
|
|
45
|
+
startClockwork: typeof startClockwork;
|
|
46
|
+
MonitorCore: typeof MonitorCore;
|
|
47
|
+
createHttpAdapter: typeof createHttpAdapter;
|
|
48
|
+
contextPlugin: ClockworkPlugin;
|
|
49
|
+
consolePlugin: ClockworkPlugin;
|
|
50
|
+
processErrorsPlugin: ClockworkPlugin;
|
|
51
|
+
pinoPlugin: ClockworkPlugin;
|
|
52
|
+
winstonPlugin: ClockworkPlugin;
|
|
53
|
+
pgPlugin: ClockworkPlugin;
|
|
54
|
+
mysql2Plugin: ClockworkPlugin;
|
|
55
|
+
defaultCorePlugins: ClockworkPlugin[];
|
|
56
|
+
defaultLogPlugins: ClockworkPlugin[];
|
|
57
|
+
defaultDbPlugins: ClockworkPlugin[];
|
|
58
|
+
getDefaultPlugins: typeof getDefaultPlugins;
|
|
59
|
+
};
|
|
60
|
+
|
|
61
|
+
export { type ClockworkInstance, type StartClockworkOptions, _default as default, startClockwork };
|