securenow 5.6.1 → 5.7.0
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/NPM_README.md +65 -15
- package/README.md +72 -24
- package/cli/run.js +133 -0
- package/cli.js +22 -1
- package/docs/INDEX.md +14 -3
- package/docs/NUXT-GUIDE.md +166 -0
- package/nextjs-webpack-config.js +77 -0
- package/nuxt-server-plugin.mjs +400 -0
- package/nuxt.d.ts +60 -0
- package/nuxt.mjs +75 -0
- package/package.json +21 -4
- package/register.js +39 -4
- package/tracing.js +11 -6
package/NPM_README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# SecureNow - Complete OpenTelemetry Observability for Node.js
|
|
2
2
|
|
|
3
|
-
OpenTelemetry instrumentation library for Node.js applications. Send distributed traces and logs to any OTLP-compatible observability backend.
|
|
3
|
+
OpenTelemetry instrumentation library for Node.js, Next.js, and Nuxt applications. Send distributed traces and logs to any OTLP-compatible observability backend.
|
|
4
4
|
|
|
5
5
|
**Features:**
|
|
6
6
|
- 🚀 Zero-config automatic instrumentation
|
|
@@ -9,6 +9,8 @@ OpenTelemetry instrumentation library for Node.js applications. Send distributed
|
|
|
9
9
|
- 🔐 Built-in sensitive data redaction
|
|
10
10
|
- 🎯 Request body capture for debugging
|
|
11
11
|
- 🔧 Fully configurable via environment variables
|
|
12
|
+
- 🖥️ Single `-r securenow/register` flag — works for both CJS and ESM apps
|
|
13
|
+
- 🟢 Native Nuxt 3 module (`securenow/nuxt`)
|
|
12
14
|
|
|
13
15
|
---
|
|
14
16
|
|
|
@@ -20,6 +22,7 @@ OpenTelemetry instrumentation library for Node.js applications. Send distributed
|
|
|
20
22
|
- [Framework-Specific Setup](#framework-specific-setup)
|
|
21
23
|
- [Express.js](#expressjs)
|
|
22
24
|
- [Next.js](#nextjs)
|
|
25
|
+
- [Nuxt 3](#nuxt-3)
|
|
23
26
|
- [Fastify](#fastify)
|
|
24
27
|
- [NestJS](#nestjs)
|
|
25
28
|
- [Koa](#koa)
|
|
@@ -62,32 +65,42 @@ export SECURENOW_INSTANCE=http://your-otlp-collector:4318
|
|
|
62
65
|
export SECURENOW_LOGGING_ENABLED=1
|
|
63
66
|
```
|
|
64
67
|
|
|
65
|
-
### 2.
|
|
68
|
+
### 2. Run Your Application
|
|
66
69
|
|
|
67
|
-
|
|
70
|
+
Add `-r securenow/register` to your start command — that's the only change:
|
|
68
71
|
|
|
69
72
|
```bash
|
|
70
|
-
|
|
73
|
+
node -r securenow/register app.js
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
ESM and CJS apps are both handled automatically (Node >=20.6 auto-registers the ESM loader hook via `module.register()`).
|
|
77
|
+
|
|
78
|
+
**package.json** example:
|
|
79
|
+
|
|
80
|
+
```json
|
|
81
|
+
"scripts": {
|
|
82
|
+
"start": "node -r securenow/register app.js",
|
|
83
|
+
"dev": "node -r securenow/register --watch app.js"
|
|
84
|
+
}
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
**Alternative: Use NODE_OPTIONS** so your existing scripts stay unchanged:
|
|
88
|
+
|
|
89
|
+
```bash
|
|
90
|
+
NODE_OPTIONS="-r securenow/register" npm start
|
|
71
91
|
```
|
|
72
92
|
|
|
73
|
-
**
|
|
93
|
+
**CJS only: Code-based initialization**
|
|
74
94
|
|
|
75
95
|
```javascript
|
|
76
|
-
// At the very top of your main file
|
|
96
|
+
// At the very top of your main file, before any other require
|
|
77
97
|
require('securenow/register');
|
|
78
98
|
|
|
79
|
-
// Your application code
|
|
80
99
|
const express = require('express');
|
|
81
100
|
const app = express();
|
|
82
101
|
// ...
|
|
83
102
|
```
|
|
84
103
|
|
|
85
|
-
### 3. Run Your Application
|
|
86
|
-
|
|
87
|
-
```bash
|
|
88
|
-
node app.js
|
|
89
|
-
```
|
|
90
|
-
|
|
91
104
|
You'll see confirmation in the console:
|
|
92
105
|
|
|
93
106
|
```
|
|
@@ -702,7 +715,7 @@ http.createServer(handler).listen(3000, () => console.log('HTTP running on port
|
|
|
702
715
|
npm install securenow hono @hono/node-server
|
|
703
716
|
```
|
|
704
717
|
|
|
705
|
-
Hono uses ESM —
|
|
718
|
+
Hono uses ESM — preload via `-r` flag (the ESM hook is auto-registered on Node >=20.6):
|
|
706
719
|
|
|
707
720
|
```javascript
|
|
708
721
|
// app.mjs
|
|
@@ -794,6 +807,42 @@ SECURENOW_NO_UUID=1
|
|
|
794
807
|
|
|
795
808
|
---
|
|
796
809
|
|
|
810
|
+
### Nuxt 3
|
|
811
|
+
|
|
812
|
+
```bash
|
|
813
|
+
npm install securenow
|
|
814
|
+
```
|
|
815
|
+
|
|
816
|
+
Add the module to `nuxt.config.ts`:
|
|
817
|
+
|
|
818
|
+
```typescript
|
|
819
|
+
export default defineNuxtConfig({
|
|
820
|
+
modules: ['securenow/nuxt'],
|
|
821
|
+
});
|
|
822
|
+
```
|
|
823
|
+
|
|
824
|
+
`.env`:
|
|
825
|
+
|
|
826
|
+
```env
|
|
827
|
+
SECURENOW_APPID=my-nuxt-app
|
|
828
|
+
SECURENOW_INSTANCE=https://freetrial.securenow.ai:4318
|
|
829
|
+
```
|
|
830
|
+
|
|
831
|
+
That's it — the Nuxt module handles OTel SDK initialization, Nitro externalization, and request tracing automatically. Optional config:
|
|
832
|
+
|
|
833
|
+
```typescript
|
|
834
|
+
export default defineNuxtConfig({
|
|
835
|
+
modules: ['securenow/nuxt'],
|
|
836
|
+
securenow: {
|
|
837
|
+
captureBody: true,
|
|
838
|
+
logging: true,
|
|
839
|
+
noUuid: true,
|
|
840
|
+
},
|
|
841
|
+
});
|
|
842
|
+
```
|
|
843
|
+
|
|
844
|
+
---
|
|
845
|
+
|
|
797
846
|
### Compatibility Matrix
|
|
798
847
|
|
|
799
848
|
| Framework | Traces | Logs | Body Capture | Notes |
|
|
@@ -809,6 +858,7 @@ SECURENOW_NO_UUID=1
|
|
|
809
858
|
| Hono | Yes | Yes | **No** | `SECURENOW_CAPTURE_BODY=0`; ESM `-r` flag |
|
|
810
859
|
| Feathers | Yes | Yes | Yes | Uses Express transport |
|
|
811
860
|
| Next.js | Yes | Yes | Yes | Use `instrumentation.ts` |
|
|
861
|
+
| Nuxt 3 | Yes | Yes | Yes | Use `securenow/nuxt` module |
|
|
812
862
|
|
|
813
863
|
---
|
|
814
864
|
|
|
@@ -1424,7 +1474,7 @@ SECURENOW_CAPTURE_BODY=0
|
|
|
1424
1474
|
## Supported Runtimes
|
|
1425
1475
|
|
|
1426
1476
|
- **Node.js:** 18+
|
|
1427
|
-
- **Frameworks:** Express, Next.js, Fastify, NestJS, Koa, Hapi, and more
|
|
1477
|
+
- **Frameworks:** Express, Next.js, Nuxt 3, Fastify, NestJS, Koa, Hapi, and more
|
|
1428
1478
|
- **Databases:** PostgreSQL, MySQL, MongoDB, Redis
|
|
1429
1479
|
- **HTTP Clients:** axios, fetch, node-fetch, got, request
|
|
1430
1480
|
- **GraphQL:** Apollo Server, GraphQL.js
|
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# SecureNow
|
|
2
2
|
|
|
3
|
-
OpenTelemetry instrumentation for Node.js
|
|
3
|
+
OpenTelemetry instrumentation for Node.js, Next.js, and Nuxt applications - send **traces and logs** to any OTLP-compatible backend (including SecureNow).
|
|
4
4
|
|
|
5
5
|
**Official npm package:** [securenow](http://securenow.ai/)
|
|
6
6
|
|
|
@@ -8,6 +8,39 @@ OpenTelemetry instrumentation for Node.js and Next.js applications - send **trac
|
|
|
8
8
|
|
|
9
9
|
## 🚀 Quick Start
|
|
10
10
|
|
|
11
|
+
### For Any Node.js App (Express, Fastify, NestJS, Koa, Hapi, etc.)
|
|
12
|
+
|
|
13
|
+
```bash
|
|
14
|
+
# 1. Install
|
|
15
|
+
npm install securenow
|
|
16
|
+
|
|
17
|
+
# 2. Set env vars
|
|
18
|
+
export SECURENOW_APPID=my-app
|
|
19
|
+
export SECURENOW_INSTANCE=https://freetrial.securenow.ai:4318
|
|
20
|
+
|
|
21
|
+
# 3. Add -r securenow/register to your start command
|
|
22
|
+
node -r securenow/register src/app.js
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
That's it. One `-r` flag is all you need — ESM and CJS apps are handled automatically (Node >=20.6 auto-registers the ESM loader hook).
|
|
26
|
+
|
|
27
|
+
> **package.json** example:
|
|
28
|
+
> ```json
|
|
29
|
+
> "scripts": {
|
|
30
|
+
> "start": "node -r securenow/register src/index.js",
|
|
31
|
+
> "dev": "node -r securenow/register --watch src/index.js"
|
|
32
|
+
> }
|
|
33
|
+
> ```
|
|
34
|
+
|
|
35
|
+
You can also use `NODE_OPTIONS` so your existing scripts stay unchanged:
|
|
36
|
+
```bash
|
|
37
|
+
NODE_OPTIONS="-r securenow/register" npm start
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
See the [All Frameworks Quick Start](./docs/ALL-FRAMEWORKS-QUICKSTART.md) for tested setup guides.
|
|
41
|
+
|
|
42
|
+
---
|
|
43
|
+
|
|
11
44
|
### For Next.js Applications
|
|
12
45
|
|
|
13
46
|
**The easiest way to add observability to Next.js!**
|
|
@@ -40,6 +73,32 @@ npx securenow init
|
|
|
40
73
|
|
|
41
74
|
---
|
|
42
75
|
|
|
76
|
+
### For Nuxt 3 Applications
|
|
77
|
+
|
|
78
|
+
```bash
|
|
79
|
+
# 1. Install
|
|
80
|
+
npm install securenow
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
Add the module to your `nuxt.config.ts`:
|
|
84
|
+
|
|
85
|
+
```ts
|
|
86
|
+
export default defineNuxtConfig({
|
|
87
|
+
modules: ['securenow/nuxt'],
|
|
88
|
+
});
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
Set environment variables in `.env`:
|
|
92
|
+
|
|
93
|
+
```bash
|
|
94
|
+
SECURENOW_APPID=my-nuxt-app
|
|
95
|
+
SECURENOW_INSTANCE=https://freetrial.securenow.ai:4318
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
**Done!** All server-side requests are now traced automatically. See the [Nuxt 3 Complete Guide](./docs/NUXT-GUIDE.md) for details.
|
|
99
|
+
|
|
100
|
+
---
|
|
101
|
+
|
|
43
102
|
### CLI — Manage Everything from the Terminal
|
|
44
103
|
|
|
45
104
|
```bash
|
|
@@ -70,29 +129,6 @@ Run `npx securenow help` for all commands. See the [CLI Reference](#cli-referenc
|
|
|
70
129
|
|
|
71
130
|
---
|
|
72
131
|
|
|
73
|
-
### For Node.js Applications (Express, Fastify, NestJS, Koa, Hapi, h3, Polka, Hono, Feathers, etc.)
|
|
74
|
-
|
|
75
|
-
```bash
|
|
76
|
-
# 1. Install
|
|
77
|
-
npm install securenow
|
|
78
|
-
|
|
79
|
-
# 2. Set environment variables
|
|
80
|
-
export SECURENOW_APPID=my-app
|
|
81
|
-
export SECURENOW_INSTANCE=https://freetrial.securenow.ai:4318
|
|
82
|
-
export SECURENOW_LOGGING_ENABLED=1
|
|
83
|
-
export SECURENOW_NO_UUID=1
|
|
84
|
-
|
|
85
|
-
# 3. Run with preload
|
|
86
|
-
NODE_OPTIONS="-r securenow/register" node app.js
|
|
87
|
-
```
|
|
88
|
-
|
|
89
|
-
That's it. Traces are captured automatically via OpenTelemetry HTTP instrumentation.
|
|
90
|
-
Since **v5.6.0**, when `SECURENOW_LOGGING_ENABLED=1`, all `console.log`/`warn`/`error` calls are
|
|
91
|
-
**automatically** forwarded as OTLP log records — no extra require needed.
|
|
92
|
-
|
|
93
|
-
See the [All Frameworks Quick Start](./docs/ALL-FRAMEWORKS-QUICKSTART.md) for tested setup guides
|
|
94
|
-
for Express, Fastify, Koa, NestJS, Hapi, h3, Polka, Micro, Hono, and Feathers.
|
|
95
|
-
|
|
96
132
|
---
|
|
97
133
|
|
|
98
134
|
## 📦 Installation
|
|
@@ -149,6 +185,7 @@ SecureNow automatically instruments:
|
|
|
149
185
|
|
|
150
186
|
### Web Frameworks
|
|
151
187
|
- ✅ Next.js (App Router & Pages Router)
|
|
188
|
+
- ✅ Nuxt 3 (Nitro server)
|
|
152
189
|
- ✅ Express.js
|
|
153
190
|
- ✅ Fastify
|
|
154
191
|
- ✅ NestJS
|
|
@@ -179,10 +216,12 @@ SecureNow automatically instruments:
|
|
|
179
216
|
|
|
180
217
|
### Quick Starts
|
|
181
218
|
- **[Next.js Quick Start](./docs/NEXTJS-QUICKSTART.md)** - Get started in 30 seconds
|
|
219
|
+
- **[Nuxt 3 Guide](./docs/NUXT-GUIDE.md)** - One-line Nuxt module setup
|
|
182
220
|
- **[Logging Quick Start](./docs/LOGGING-QUICKSTART.md)** - Add logging in 2 minutes
|
|
183
221
|
|
|
184
222
|
### Complete Guides
|
|
185
223
|
- **[Next.js Complete Guide](./docs/NEXTJS-GUIDE.md)** - Full Next.js integration guide
|
|
224
|
+
- **[Nuxt 3 Complete Guide](./docs/NUXT-GUIDE.md)** - Full Nuxt 3 integration guide
|
|
186
225
|
- **[Logging Complete Guide](./docs/LOGGING-GUIDE.md)** - Full logging setup for all frameworks
|
|
187
226
|
- **[📚 Complete Documentation](./docs/INDEX.md)** - All guides and references
|
|
188
227
|
|
|
@@ -195,6 +234,15 @@ SecureNow automatically instruments:
|
|
|
195
234
|
|
|
196
235
|
After installing the package, the `securenow` CLI is available via `npx securenow` or globally after `npm install -g securenow`.
|
|
197
236
|
|
|
237
|
+
### Run (convenience wrapper)
|
|
238
|
+
|
|
239
|
+
| Command | Description |
|
|
240
|
+
|---------|-------------|
|
|
241
|
+
| `securenow run <script>` | Run a Node.js app with `-r securenow/register` injected |
|
|
242
|
+
| `securenow run --watch <script>` | Same, with Node.js watch mode |
|
|
243
|
+
|
|
244
|
+
Most users won't need this — just add `-r securenow/register` to your existing start script.
|
|
245
|
+
|
|
198
246
|
### Authentication
|
|
199
247
|
|
|
200
248
|
| Command | Description |
|
package/cli/run.js
ADDED
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const { spawn } = require('child_process');
|
|
4
|
+
const path = require('path');
|
|
5
|
+
const fs = require('fs');
|
|
6
|
+
const ui = require('./ui');
|
|
7
|
+
|
|
8
|
+
function isESM(scriptPath) {
|
|
9
|
+
if (scriptPath.endsWith('.mjs')) return true;
|
|
10
|
+
if (scriptPath.endsWith('.cjs')) return false;
|
|
11
|
+
|
|
12
|
+
let dir = path.resolve(path.dirname(scriptPath));
|
|
13
|
+
while (true) {
|
|
14
|
+
const pkgPath = path.join(dir, 'package.json');
|
|
15
|
+
if (fs.existsSync(pkgPath)) {
|
|
16
|
+
try {
|
|
17
|
+
const pkg = JSON.parse(fs.readFileSync(pkgPath, 'utf8'));
|
|
18
|
+
return pkg.type === 'module';
|
|
19
|
+
} catch { return false; }
|
|
20
|
+
}
|
|
21
|
+
const parent = path.dirname(dir);
|
|
22
|
+
if (parent === dir) break;
|
|
23
|
+
dir = parent;
|
|
24
|
+
}
|
|
25
|
+
return false;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
function resolveSecurenowRegister() {
|
|
29
|
+
// When running from the published package, securenow/register resolves to our own register.js.
|
|
30
|
+
// When running from the monorepo, resolve relative to this file.
|
|
31
|
+
try {
|
|
32
|
+
return require.resolve('securenow/register');
|
|
33
|
+
} catch {
|
|
34
|
+
return path.resolve(__dirname, '..', 'register.js');
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
function resolveESMHook() {
|
|
39
|
+
// --import uses ESM resolution which requires file:// URLs for absolute paths
|
|
40
|
+
// on Windows. Using the bare specifier lets Node's own resolver handle it.
|
|
41
|
+
try {
|
|
42
|
+
const resolved = require.resolve('@opentelemetry/instrumentation/hook.mjs');
|
|
43
|
+
const { pathToFileURL } = require('url');
|
|
44
|
+
return pathToFileURL(resolved).href;
|
|
45
|
+
} catch {
|
|
46
|
+
return '@opentelemetry/instrumentation/hook.mjs';
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* securenow run [node-flags...] <script> [app-args...]
|
|
52
|
+
*
|
|
53
|
+
* Spawns node with the correct OTel preload flags.
|
|
54
|
+
* Passes through Node flags (--watch, --inspect, etc.) and app arguments.
|
|
55
|
+
*
|
|
56
|
+
* We re-parse from process.argv directly so that flags like --watch and
|
|
57
|
+
* --inspect are forwarded to node verbatim (the CLI's own arg parser
|
|
58
|
+
* would otherwise consume them).
|
|
59
|
+
*/
|
|
60
|
+
function run(rawArgs) {
|
|
61
|
+
// rawArgs comes directly from process.argv, everything after `run` (or the file path)
|
|
62
|
+
if (!rawArgs || rawArgs.length === 0) {
|
|
63
|
+
ui.error('Missing script path.');
|
|
64
|
+
console.log('');
|
|
65
|
+
console.log(` ${ui.c.bold('Usage:')} securenow run [node-flags] <script> [app-args]`);
|
|
66
|
+
console.log('');
|
|
67
|
+
console.log(` ${ui.c.bold('Examples:')}`);
|
|
68
|
+
console.log(` securenow run src/index.js`);
|
|
69
|
+
console.log(` securenow run --watch src/index.js`);
|
|
70
|
+
console.log(` securenow run --inspect src/server.js --port 3000`);
|
|
71
|
+
console.log('');
|
|
72
|
+
process.exit(1);
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
const args = rawArgs;
|
|
76
|
+
|
|
77
|
+
// Split into: node flags (before the script), script path, and app args (after)
|
|
78
|
+
const nodeFlags = [];
|
|
79
|
+
let scriptIdx = -1;
|
|
80
|
+
|
|
81
|
+
for (let i = 0; i < args.length; i++) {
|
|
82
|
+
if (args[i].startsWith('-')) {
|
|
83
|
+
nodeFlags.push(args[i]);
|
|
84
|
+
} else {
|
|
85
|
+
scriptIdx = i;
|
|
86
|
+
break;
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
if (scriptIdx === -1) {
|
|
91
|
+
ui.error('No script path found. Provide a .js/.mjs/.ts file to run.');
|
|
92
|
+
process.exit(1);
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
const scriptPath = args[scriptIdx];
|
|
96
|
+
const appArgs = args.slice(scriptIdx + 1);
|
|
97
|
+
|
|
98
|
+
const esm = isESM(scriptPath);
|
|
99
|
+
const registerPath = resolveSecurenowRegister();
|
|
100
|
+
|
|
101
|
+
const otelFlags = [];
|
|
102
|
+
if (esm) {
|
|
103
|
+
otelFlags.push('--import', resolveESMHook());
|
|
104
|
+
}
|
|
105
|
+
otelFlags.push('--require', registerPath);
|
|
106
|
+
|
|
107
|
+
const finalArgs = [...otelFlags, ...nodeFlags, scriptPath, ...appArgs];
|
|
108
|
+
|
|
109
|
+
const nodeExe = process.execPath;
|
|
110
|
+
|
|
111
|
+
if (process.env.SECURENOW_DEBUG) {
|
|
112
|
+
console.log(`[securenow] ${ui.c.dim('exec:')} ${nodeExe} ${finalArgs.join(' ')}`);
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
const child = spawn(nodeExe, finalArgs, {
|
|
116
|
+
stdio: 'inherit',
|
|
117
|
+
env: process.env,
|
|
118
|
+
cwd: process.cwd(),
|
|
119
|
+
});
|
|
120
|
+
|
|
121
|
+
child.on('close', (code) => process.exit(code ?? 1));
|
|
122
|
+
child.on('error', (err) => {
|
|
123
|
+
ui.error(`Failed to start: ${err.message}`);
|
|
124
|
+
process.exit(1);
|
|
125
|
+
});
|
|
126
|
+
|
|
127
|
+
// Forward termination signals to the child
|
|
128
|
+
for (const sig of ['SIGINT', 'SIGTERM', 'SIGHUP']) {
|
|
129
|
+
process.on(sig, () => child.kill(sig));
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
module.exports = { run };
|
package/cli.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
1
|
+
#!/usr/bin/env node
|
|
2
2
|
'use strict';
|
|
3
3
|
|
|
4
4
|
const ui = require('./cli/ui');
|
|
@@ -235,6 +235,13 @@ const COMMANDS = {
|
|
|
235
235
|
flags: { typescript: 'Force TypeScript', javascript: 'Force JavaScript', src: 'Create in src/', root: 'Create in root', force: 'Overwrite existing' },
|
|
236
236
|
run: (a, f) => require('./cli/init').init(a, f),
|
|
237
237
|
},
|
|
238
|
+
run: {
|
|
239
|
+
desc: 'Run a Node.js app with automatic OTel instrumentation',
|
|
240
|
+
usage: 'securenow run [node-flags] <script> [app-args]',
|
|
241
|
+
flags: { watch: 'Enable Node.js watch mode', inspect: 'Enable Node.js inspector' },
|
|
242
|
+
rawArgv: true,
|
|
243
|
+
run: (rawArgs) => require('./cli/run').run(rawArgs),
|
|
244
|
+
},
|
|
238
245
|
version: {
|
|
239
246
|
desc: 'Show CLI version',
|
|
240
247
|
run: () => {
|
|
@@ -293,6 +300,7 @@ function showHelp(commandName) {
|
|
|
293
300
|
showBanner();
|
|
294
301
|
|
|
295
302
|
const groups = {
|
|
303
|
+
'Run': ['run'],
|
|
296
304
|
'Authentication': ['login', 'logout', 'whoami'],
|
|
297
305
|
'Applications': ['apps', 'init', 'status'],
|
|
298
306
|
'Observe': ['traces', 'logs', 'analytics'],
|
|
@@ -334,11 +342,24 @@ async function main() {
|
|
|
334
342
|
|
|
335
343
|
const cmd = COMMANDS[cmdName];
|
|
336
344
|
if (!cmd) {
|
|
345
|
+
// Auto-detect: if the first arg looks like a file path, treat it as `securenow run <file>`
|
|
346
|
+
if (/\.(m?[jt]sx?|cjs)$/.test(cmdName) || cmdName.includes('/') || cmdName.includes('\\')) {
|
|
347
|
+
return COMMANDS.run.run(process.argv.slice(2));
|
|
348
|
+
}
|
|
337
349
|
ui.error(`Unknown command: ${cmdName}`);
|
|
338
350
|
ui.info('Run `securenow help` for a list of commands.');
|
|
339
351
|
process.exit(1);
|
|
340
352
|
}
|
|
341
353
|
|
|
354
|
+
if (cmd.rawArgv) {
|
|
355
|
+
// Pass raw argv (everything after the command name) so the command can
|
|
356
|
+
// forward flags like --watch, --inspect verbatim to child processes.
|
|
357
|
+
const cmdIdx = process.argv.indexOf(cmdName);
|
|
358
|
+
const rawArgs = cmdIdx !== -1 ? process.argv.slice(cmdIdx + 1) : positional.slice(1);
|
|
359
|
+
await cmd.run(rawArgs);
|
|
360
|
+
return;
|
|
361
|
+
}
|
|
362
|
+
|
|
342
363
|
if (cmd.run && !cmd.sub) {
|
|
343
364
|
await cmd.run(positional.slice(1), flags);
|
|
344
365
|
return;
|
package/docs/INDEX.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# SecureNow Documentation
|
|
2
2
|
|
|
3
|
-
Complete documentation for SecureNow - OpenTelemetry instrumentation for Node.js
|
|
3
|
+
Complete documentation for SecureNow - OpenTelemetry instrumentation for Node.js, Next.js, and Nuxt with tracing and logging.
|
|
4
4
|
|
|
5
5
|
## 📚 Table of Contents
|
|
6
6
|
|
|
@@ -39,6 +39,12 @@ Complete documentation for SecureNow - OpenTelemetry instrumentation for Node.js
|
|
|
39
39
|
- Server components
|
|
40
40
|
- Middleware
|
|
41
41
|
- Deployment guides
|
|
42
|
+
- **[Nuxt 3 Complete Setup](NUXT-GUIDE.md)** - Step-by-step Nuxt 3 guide
|
|
43
|
+
- One-line module setup
|
|
44
|
+
- Nuxt config options
|
|
45
|
+
- Nitro server tracing
|
|
46
|
+
- Body capture & logging
|
|
47
|
+
- Deployment guides
|
|
42
48
|
|
|
43
49
|
### 📦 Next.js Integration
|
|
44
50
|
|
|
@@ -112,6 +118,10 @@ Complete documentation for SecureNow - OpenTelemetry instrumentation for Node.js
|
|
|
112
118
|
2. Complete guide: [Next.js Setup Complete](NEXTJS-SETUP-COMPLETE.md)
|
|
113
119
|
3. Legacy guide: [Next.js Quickstart](NEXTJS-QUICKSTART.md)
|
|
114
120
|
|
|
121
|
+
### "I'm using Nuxt 3"
|
|
122
|
+
1. Complete guide: [Nuxt 3 Guide](NUXT-GUIDE.md)
|
|
123
|
+
2. Add `securenow/nuxt` to `modules` in `nuxt.config.ts` — that's it
|
|
124
|
+
|
|
115
125
|
### "I want to add logging to my app"
|
|
116
126
|
1. Start with [Logging Quick Start](LOGGING-QUICKSTART.md)
|
|
117
127
|
2. For complete guide: [Logging Complete Guide](LOGGING-GUIDE.md)
|
|
@@ -148,6 +158,7 @@ Complete documentation for SecureNow - OpenTelemetry instrumentation for Node.js
|
|
|
148
158
|
### Complete Framework Guides
|
|
149
159
|
- **Express.js Setup Guide** - Complete Express.js reference
|
|
150
160
|
- **Next.js Setup Complete** - Complete Next.js reference
|
|
161
|
+
- **Nuxt 3 Guide** - Complete Nuxt 3 reference
|
|
151
162
|
- **Logging Complete Guide** - Complete logging reference
|
|
152
163
|
|
|
153
164
|
### Quick Start Guides
|
|
@@ -202,5 +213,5 @@ Key documentation files included in the npm package:
|
|
|
202
213
|
|
|
203
214
|
---
|
|
204
215
|
|
|
205
|
-
**Last Updated:**
|
|
206
|
-
**Package Version:**
|
|
216
|
+
**Last Updated:** April 2, 2026
|
|
217
|
+
**Package Version:** 5.7.0+
|
|
@@ -0,0 +1,166 @@
|
|
|
1
|
+
# SecureNow — Nuxt 3 Setup Guide
|
|
2
|
+
|
|
3
|
+
## Quick Start (1 minute)
|
|
4
|
+
|
|
5
|
+
### 1. Install
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install securenow
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
### 2. Add the module to `nuxt.config.ts`
|
|
12
|
+
|
|
13
|
+
```ts
|
|
14
|
+
export default defineNuxtConfig({
|
|
15
|
+
modules: ['securenow/nuxt'],
|
|
16
|
+
});
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
### 3. Set environment variables
|
|
20
|
+
|
|
21
|
+
Create a `.env` file in your project root:
|
|
22
|
+
|
|
23
|
+
```env
|
|
24
|
+
SECURENOW_APPID=my-nuxt-app
|
|
25
|
+
SECURENOW_INSTANCE=https://freetrial.securenow.ai:4318
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
### 4. Start your app
|
|
29
|
+
|
|
30
|
+
```bash
|
|
31
|
+
nuxt dev
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
You should see in the console:
|
|
35
|
+
|
|
36
|
+
```
|
|
37
|
+
[securenow] Nuxt module loaded — server plugin registered
|
|
38
|
+
[securenow] 🚀 Nuxt OTel SDK started → https://freetrial.securenow.ai:4318/v1/traces
|
|
39
|
+
[securenow] service.name=my-nuxt-app instance.id=my-nuxt-app-...
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
That's it — all server-side requests are now traced.
|
|
43
|
+
|
|
44
|
+
---
|
|
45
|
+
|
|
46
|
+
## Configuration
|
|
47
|
+
|
|
48
|
+
### Module options in `nuxt.config.ts`
|
|
49
|
+
|
|
50
|
+
```ts
|
|
51
|
+
export default defineNuxtConfig({
|
|
52
|
+
modules: ['securenow/nuxt'],
|
|
53
|
+
securenow: {
|
|
54
|
+
serviceName: 'my-nuxt-app', // overrides SECURENOW_APPID
|
|
55
|
+
endpoint: 'http://host:4318', // overrides SECURENOW_INSTANCE
|
|
56
|
+
noUuid: true, // single service.name (no UUID suffix)
|
|
57
|
+
captureBody: true, // capture POST/PUT/PATCH bodies
|
|
58
|
+
logging: true, // forward console.* as OTLP logs
|
|
59
|
+
},
|
|
60
|
+
});
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
### Environment variables
|
|
64
|
+
|
|
65
|
+
All standard SecureNow env vars are supported:
|
|
66
|
+
|
|
67
|
+
| Variable | Description | Default |
|
|
68
|
+
|----------|-------------|---------|
|
|
69
|
+
| `SECURENOW_APPID` | Service name | `nuxt-app-<uuid>` |
|
|
70
|
+
| `SECURENOW_INSTANCE` | OTLP base URL | `https://freetrial.securenow.ai:4318` |
|
|
71
|
+
| `SECURENOW_NO_UUID` | Don't append UUID to service name | `false` |
|
|
72
|
+
| `SECURENOW_LOGGING_ENABLED` | Forward console logs as OTLP | `false` |
|
|
73
|
+
| `SECURENOW_CAPTURE_BODY` | Capture request bodies | `false` |
|
|
74
|
+
| `SECURENOW_MAX_BODY_SIZE` | Max body size to capture (bytes) | `10240` |
|
|
75
|
+
| `SECURENOW_SENSITIVE_FIELDS` | Extra fields to redact (CSV) | _(built-in list)_ |
|
|
76
|
+
| `OTEL_EXPORTER_OTLP_ENDPOINT` | Alternative OTLP base URL | — |
|
|
77
|
+
| `OTEL_EXPORTER_OTLP_HEADERS` | OTLP headers (k=v,k2=v2) | — |
|
|
78
|
+
|
|
79
|
+
---
|
|
80
|
+
|
|
81
|
+
## What gets traced
|
|
82
|
+
|
|
83
|
+
### Automatic (out of the box)
|
|
84
|
+
|
|
85
|
+
- All Nitro server handler requests (API routes, SSR pages, middleware)
|
|
86
|
+
- HTTP method, path, status code, duration
|
|
87
|
+
- Client IP address (with proxy-aware resolution)
|
|
88
|
+
- User-Agent, Referer, Origin, Host
|
|
89
|
+
- Security header presence (auth, cookies, CSRF)
|
|
90
|
+
- Request IDs and correlation headers
|
|
91
|
+
|
|
92
|
+
### With `captureBody: true`
|
|
93
|
+
|
|
94
|
+
- POST/PUT/PATCH request bodies (JSON, form-urlencoded, GraphQL)
|
|
95
|
+
- Sensitive fields auto-redacted (passwords, tokens, etc.)
|
|
96
|
+
- Bodies larger than `SECURENOW_MAX_BODY_SIZE` are skipped
|
|
97
|
+
|
|
98
|
+
### With `logging: true`
|
|
99
|
+
|
|
100
|
+
- All `console.log/info/warn/error/debug` calls forwarded as OTLP log records
|
|
101
|
+
- Logs correlated with active trace spans
|
|
102
|
+
|
|
103
|
+
---
|
|
104
|
+
|
|
105
|
+
## Comparison with Next.js integration
|
|
106
|
+
|
|
107
|
+
| Feature | Nuxt (`securenow/nuxt`) | Next.js (`securenow/nextjs`) |
|
|
108
|
+
|---------|-------------------------|------------------------------|
|
|
109
|
+
| Setup | Add to `modules` array | Create `instrumentation.ts` |
|
|
110
|
+
| Config | `nuxt.config.ts` | `.env.local` + `next.config.js` |
|
|
111
|
+
| Server tracing | Nitro hooks | HTTP instrumentation |
|
|
112
|
+
| Edge runtime | Not supported | Skipped gracefully |
|
|
113
|
+
| Vercel support | Via env vars | `@vercel/otel` integration |
|
|
114
|
+
| Body capture | HTTP instrumentation | Middleware + `Request.clone()` |
|
|
115
|
+
| Logging | Console patching | Console patching |
|
|
116
|
+
|
|
117
|
+
---
|
|
118
|
+
|
|
119
|
+
## Deployment
|
|
120
|
+
|
|
121
|
+
### Node.js server (PM2, Docker, etc.)
|
|
122
|
+
|
|
123
|
+
Works out of the box with `nuxt build && node .output/server/index.mjs`.
|
|
124
|
+
|
|
125
|
+
### Vercel / Netlify / Cloudflare
|
|
126
|
+
|
|
127
|
+
Set env vars in the platform dashboard:
|
|
128
|
+
|
|
129
|
+
```
|
|
130
|
+
SECURENOW_APPID=my-nuxt-app
|
|
131
|
+
SECURENOW_INSTANCE=https://your-otlp-backend:4318
|
|
132
|
+
```
|
|
133
|
+
|
|
134
|
+
> Note: On edge runtimes (Cloudflare Workers, Vercel Edge), some Node.js-specific
|
|
135
|
+
> instrumentations may not be available. Server-handler tracing via Nitro hooks
|
|
136
|
+
> still works.
|
|
137
|
+
|
|
138
|
+
---
|
|
139
|
+
|
|
140
|
+
## Troubleshooting
|
|
141
|
+
|
|
142
|
+
### No traces appearing
|
|
143
|
+
|
|
144
|
+
1. Check that `SECURENOW_APPID` and `SECURENOW_INSTANCE` are set
|
|
145
|
+
2. Look for `[securenow] 🚀 Nuxt OTel SDK started` in the console
|
|
146
|
+
3. Verify the OTLP endpoint is reachable from your server
|
|
147
|
+
|
|
148
|
+
### Module not loading
|
|
149
|
+
|
|
150
|
+
Make sure you're using Nuxt 3 (`nuxt: ">=3.0.0"`) and the module is listed
|
|
151
|
+
in the `modules` array (not `buildModules`).
|
|
152
|
+
|
|
153
|
+
### OpenTelemetry packages bundled by Nitro
|
|
154
|
+
|
|
155
|
+
The module automatically externalizes OTel packages. If you see bundling errors,
|
|
156
|
+
manually add to `nuxt.config.ts`:
|
|
157
|
+
|
|
158
|
+
```ts
|
|
159
|
+
export default defineNuxtConfig({
|
|
160
|
+
nitro: {
|
|
161
|
+
externals: {
|
|
162
|
+
external: ['securenow', '@opentelemetry/api', '@opentelemetry/sdk-node'],
|
|
163
|
+
},
|
|
164
|
+
},
|
|
165
|
+
});
|
|
166
|
+
```
|