@nest-rn-lens/nest 0.1.0 → 0.1.2
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 +5 -5
- package/dist/cjs/reporter.d.ts +6 -0
- package/dist/cjs/reporter.js +15 -6
- package/dist/esm/reporter.d.ts +6 -0
- package/dist/esm/reporter.js +14 -6
- package/package.json +11 -2
package/README.md
CHANGED
|
@@ -11,9 +11,9 @@ the status, and the time it took.
|
|
|
11
11
|
```
|
|
12
12
|
|
|
13
13
|
It is the server half of **NestRN Lens**, a toolkit for Turborepo monorepos with
|
|
14
|
-
a NestJS API and a React Native (Expo) app. On its own it gives you readable
|
|
15
|
-
request logs and a typed event for every call. With the NestRN Lens VS Code
|
|
16
|
-
extension, those events become a live traffic panel where you can click any
|
|
14
|
+
a NestJS API and a React Native (Expo) or Next.js app. On its own it gives you readable
|
|
15
|
+
request logs and a typed event for every call. With the [NestRN Lens VS Code
|
|
16
|
+
extension](https://marketplace.visualstudio.com/items?itemName=IsaiasDiaz.nest-rn-lens), those events become a live traffic panel where you can click any
|
|
17
17
|
request to open the screen that made it or the handler that answered it.
|
|
18
18
|
|
|
19
19
|
## Install
|
|
@@ -72,7 +72,7 @@ adds that with three headers:
|
|
|
72
72
|
| Header | Example | Used for |
|
|
73
73
|
| ------------------------- | ----------------------------------------------- | ------------------------------------------------- |
|
|
74
74
|
| `x-nest-rn-lens-app` | `mobile` | Which app made the request |
|
|
75
|
-
| `x-nest-rn-lens-caller` | `/repo/apps/mobile/src/screens/orders.tsx:23` | The file and line that made it
|
|
75
|
+
| `x-nest-rn-lens-caller` | `/repo/apps/mobile/src/screens/orders.tsx:23` | The file and line that made it, or the page path for web apps (`/orders/42`) |
|
|
76
76
|
| `x-nest-rn-lens-trace-id` | `5f0c…` | Linking every hop of one request chain |
|
|
77
77
|
|
|
78
78
|
You don't have to write these by hand. The upcoming React Native client,
|
|
@@ -184,7 +184,7 @@ response. Native React Native apps don't use CORS at all.
|
|
|
184
184
|
| ----------------------------- | ----------------------------------------------------------------- | ------------- |
|
|
185
185
|
| `@nest-rn-lens/nest` | This interceptor | Available |
|
|
186
186
|
| `@nest-rn-lens/react-native` | `fetch` wrapper that sends the app name and the calling screen | Coming soon |
|
|
187
|
-
| NestRN Lens for VS Code
|
|
187
|
+
| [NestRN Lens for VS Code](https://marketplace.visualstudio.com/items?itemName=IsaiasDiaz.nest-rn-lens) | Live traffic panel with the app running in a phone frame | Available |
|
|
188
188
|
|
|
189
189
|
## Development
|
|
190
190
|
|
package/dist/cjs/reporter.d.ts
CHANGED
|
@@ -10,3 +10,9 @@ export declare class NestRnLensReporter {
|
|
|
10
10
|
private describe;
|
|
11
11
|
private shortPath;
|
|
12
12
|
}
|
|
13
|
+
/**
|
|
14
|
+
* Callers that are source locations are shown relative to the monorepo root
|
|
15
|
+
* (clients send absolute paths so editors can open them). Anything else, such as
|
|
16
|
+
* a web page path like "/orders/42", is shown as sent.
|
|
17
|
+
*/
|
|
18
|
+
export declare function formatCaller(caller: string, repoRoot: string): string;
|
package/dist/cjs/reporter.js
CHANGED
|
@@ -13,6 +13,7 @@ var __param = (this && this.__param) || function (paramIndex, decorator) {
|
|
|
13
13
|
};
|
|
14
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
15
|
exports.NestRnLensReporter = void 0;
|
|
16
|
+
exports.formatCaller = formatCaller;
|
|
16
17
|
const common_1 = require("@nestjs/common");
|
|
17
18
|
const node_fs_1 = require("node:fs");
|
|
18
19
|
const node_path_1 = require("node:path");
|
|
@@ -48,14 +49,12 @@ let NestRnLensReporter = class NestRnLensReporter {
|
|
|
48
49
|
const from = [`${source.app} (${source.platform})`, this.shortPath(source.caller)].filter(Boolean).join(' ');
|
|
49
50
|
return `${from} → ${target.method} ${target.route} → ${target.controller}.${target.handler} ${status} ${durationMs}ms`;
|
|
50
51
|
}
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
if (!file?.startsWith('/')) {
|
|
55
|
-
return file;
|
|
52
|
+
shortPath(caller) {
|
|
53
|
+
if (!caller || !SOURCE_LOCATION.test(caller)) {
|
|
54
|
+
return caller;
|
|
56
55
|
}
|
|
57
56
|
this.repoRoot ??= findRepoRoot(process.cwd());
|
|
58
|
-
return (
|
|
57
|
+
return formatCaller(caller, this.repoRoot);
|
|
59
58
|
}
|
|
60
59
|
};
|
|
61
60
|
exports.NestRnLensReporter = NestRnLensReporter;
|
|
@@ -64,6 +63,16 @@ exports.NestRnLensReporter = NestRnLensReporter = __decorate([
|
|
|
64
63
|
__param(0, (0, common_1.Inject)(constants_js_1.NEST_RN_LENS_OPTIONS)),
|
|
65
64
|
__metadata("design:paramtypes", [Object])
|
|
66
65
|
], NestRnLensReporter);
|
|
66
|
+
// "/repo/apps/mobile/src/screens/Orders.tsx:23": an absolute file path plus a line.
|
|
67
|
+
const SOURCE_LOCATION = /^\/.+:\d+$/;
|
|
68
|
+
/**
|
|
69
|
+
* Callers that are source locations are shown relative to the monorepo root
|
|
70
|
+
* (clients send absolute paths so editors can open them). Anything else, such as
|
|
71
|
+
* a web page path like "/orders/42", is shown as sent.
|
|
72
|
+
*/
|
|
73
|
+
function formatCaller(caller, repoRoot) {
|
|
74
|
+
return SOURCE_LOCATION.test(caller) ? (0, node_path_1.relative)(repoRoot, caller) : caller;
|
|
75
|
+
}
|
|
67
76
|
const ROOT_MARKERS = ['turbo.json', 'pnpm-workspace.yaml', '.git'];
|
|
68
77
|
function findRepoRoot(from) {
|
|
69
78
|
let dir = from;
|
package/dist/esm/reporter.d.ts
CHANGED
|
@@ -10,3 +10,9 @@ export declare class NestRnLensReporter {
|
|
|
10
10
|
private describe;
|
|
11
11
|
private shortPath;
|
|
12
12
|
}
|
|
13
|
+
/**
|
|
14
|
+
* Callers that are source locations are shown relative to the monorepo root
|
|
15
|
+
* (clients send absolute paths so editors can open them). Anything else, such as
|
|
16
|
+
* a web page path like "/orders/42", is shown as sent.
|
|
17
|
+
*/
|
|
18
|
+
export declare function formatCaller(caller: string, repoRoot: string): string;
|
package/dist/esm/reporter.js
CHANGED
|
@@ -45,14 +45,12 @@ let NestRnLensReporter = class NestRnLensReporter {
|
|
|
45
45
|
const from = [`${source.app} (${source.platform})`, this.shortPath(source.caller)].filter(Boolean).join(' ');
|
|
46
46
|
return `${from} → ${target.method} ${target.route} → ${target.controller}.${target.handler} ${status} ${durationMs}ms`;
|
|
47
47
|
}
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
if (!file?.startsWith('/')) {
|
|
52
|
-
return file;
|
|
48
|
+
shortPath(caller) {
|
|
49
|
+
if (!caller || !SOURCE_LOCATION.test(caller)) {
|
|
50
|
+
return caller;
|
|
53
51
|
}
|
|
54
52
|
this.repoRoot ??= findRepoRoot(process.cwd());
|
|
55
|
-
return
|
|
53
|
+
return formatCaller(caller, this.repoRoot);
|
|
56
54
|
}
|
|
57
55
|
};
|
|
58
56
|
NestRnLensReporter = __decorate([
|
|
@@ -61,6 +59,16 @@ NestRnLensReporter = __decorate([
|
|
|
61
59
|
__metadata("design:paramtypes", [Object])
|
|
62
60
|
], NestRnLensReporter);
|
|
63
61
|
export { NestRnLensReporter };
|
|
62
|
+
// "/repo/apps/mobile/src/screens/Orders.tsx:23": an absolute file path plus a line.
|
|
63
|
+
const SOURCE_LOCATION = /^\/.+:\d+$/;
|
|
64
|
+
/**
|
|
65
|
+
* Callers that are source locations are shown relative to the monorepo root
|
|
66
|
+
* (clients send absolute paths so editors can open them). Anything else, such as
|
|
67
|
+
* a web page path like "/orders/42", is shown as sent.
|
|
68
|
+
*/
|
|
69
|
+
export function formatCaller(caller, repoRoot) {
|
|
70
|
+
return SOURCE_LOCATION.test(caller) ? relative(repoRoot, caller) : caller;
|
|
71
|
+
}
|
|
64
72
|
const ROOT_MARKERS = ['turbo.json', 'pnpm-workspace.yaml', '.git'];
|
|
65
73
|
function findRepoRoot(from) {
|
|
66
74
|
let dir = from;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nest-rn-lens/nest",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.2",
|
|
4
4
|
"description": "NestJS interceptor that reports every request together with the React Native screen that made it. Part of NestRN Lens.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"nestjs",
|
|
@@ -12,10 +12,19 @@
|
|
|
12
12
|
"monorepo",
|
|
13
13
|
"observability",
|
|
14
14
|
"tracing",
|
|
15
|
-
"devtools"
|
|
15
|
+
"devtools",
|
|
16
|
+
"nextjs"
|
|
16
17
|
],
|
|
17
18
|
"license": "MIT",
|
|
18
19
|
"author": "isa",
|
|
20
|
+
"repository": {
|
|
21
|
+
"type": "git",
|
|
22
|
+
"url": "git+https://github.com/isa95Ar/nest-rn-lens-nest.git"
|
|
23
|
+
},
|
|
24
|
+
"homepage": "https://github.com/isa95Ar/nest-rn-lens-nest#readme",
|
|
25
|
+
"bugs": {
|
|
26
|
+
"url": "https://github.com/isa95Ar/nest-rn-lens-nest/issues"
|
|
27
|
+
},
|
|
19
28
|
"main": "./dist/cjs/index.js",
|
|
20
29
|
"types": "./dist/cjs/index.d.ts",
|
|
21
30
|
"exports": {
|