@modern-js/main-doc 0.0.0-nightly-20231214170701 → 0.0.0-nightly-20231216170634
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.
@@ -91,7 +91,7 @@ The execution of the `next` function does not affect built-in processes, only co
|
|
91
91
|
```ts
|
92
92
|
export const Middleware = () => async (ctx, next) => {
|
93
93
|
const start = Date.now();
|
94
|
-
ctx.res.once('finish', () => {
|
94
|
+
ctx.source.res.once('finish', () => {
|
95
95
|
console.log(Date.now() - start);
|
96
96
|
});
|
97
97
|
};
|
@@ -103,8 +103,8 @@ Modern.js provides `res.locals` to store local variables for the current request
|
|
103
103
|
|
104
104
|
```ts
|
105
105
|
export const Middleware = () => async (ctx, next) => {
|
106
|
-
ctx.
|
107
|
-
ctx.
|
106
|
+
ctx.response.locals.id = 'Modern.js';
|
107
|
+
ctx.response.locals.rpc = createRpcInstance();
|
108
108
|
};
|
109
109
|
```
|
110
110
|
|
@@ -91,7 +91,7 @@ type MiddlewareContext = {
|
|
91
91
|
```ts
|
92
92
|
export const Middleware = () => async (ctx, next) => {
|
93
93
|
const start = Date.now();
|
94
|
-
ctx.res.once('finish', () => {
|
94
|
+
ctx.source.res.once('finish', () => {
|
95
95
|
console.log(Date.now() - start);
|
96
96
|
});
|
97
97
|
};
|
@@ -99,12 +99,12 @@ export const Middleware = () => async (ctx, next) => {
|
|
99
99
|
|
100
100
|
### 注入服务端工具 & 数据
|
101
101
|
|
102
|
-
Modern.js 提供了 `
|
102
|
+
Modern.js 提供了 `response.locals` 属性用来存放当前请求的局部变量。
|
103
103
|
|
104
104
|
```ts
|
105
105
|
export const Middleware = () => async (ctx, next) => {
|
106
|
-
ctx.
|
107
|
-
ctx.
|
106
|
+
ctx.response.locals.id = 'Modern.js';
|
107
|
+
ctx.response.locals.rpc = createRpcInstance();
|
108
108
|
};
|
109
109
|
```
|
110
110
|
|
package/package.json
CHANGED
@@ -15,17 +15,17 @@
|
|
15
15
|
"modern",
|
16
16
|
"modern.js"
|
17
17
|
],
|
18
|
-
"version": "0.0.0-nightly-
|
18
|
+
"version": "0.0.0-nightly-20231216170634",
|
19
19
|
"publishConfig": {
|
20
20
|
"registry": "https://registry.npmjs.org/",
|
21
21
|
"access": "public",
|
22
22
|
"provenance": true
|
23
23
|
},
|
24
24
|
"dependencies": {
|
25
|
-
"@modern-js/sandpack-react": "0.0.0-nightly-
|
25
|
+
"@modern-js/sandpack-react": "0.0.0-nightly-20231216170634"
|
26
26
|
},
|
27
27
|
"peerDependencies": {
|
28
|
-
"@modern-js/builder-doc": "0.0.0-nightly-
|
28
|
+
"@modern-js/builder-doc": "0.0.0-nightly-20231216170634"
|
29
29
|
},
|
30
30
|
"devDependencies": {
|
31
31
|
"classnames": "^2",
|
@@ -39,8 +39,8 @@
|
|
39
39
|
"@rspress/shared": "1.8.2",
|
40
40
|
"@types/node": "^16",
|
41
41
|
"@types/fs-extra": "9.0.13",
|
42
|
-
"@modern-js/
|
43
|
-
"@modern-js/doc
|
42
|
+
"@modern-js/doc-plugin-auto-sidebar": "0.0.0-nightly-20231216170634",
|
43
|
+
"@modern-js/builder-doc": "0.0.0-nightly-20231216170634"
|
44
44
|
},
|
45
45
|
"scripts": {
|
46
46
|
"dev": "rspress dev",
|