@modern-js/plugin-express 1.7.3-beta.0 → 1.15.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/CHANGELOG.md CHANGED
@@ -1,5 +1,29 @@
1
1
  # @modern-js/plugin-express
2
2
 
3
+ ## 1.15.0
4
+
5
+ ### Minor Changes
6
+
7
+ - 1f8b492: feat: support afterLambdaRegisted hook
8
+
9
+ ### Patch Changes
10
+
11
+ - c0d8dac: fix: remove package adapter-helpers and bff runtime export
12
+ - 4524de6: fix: add server hook and types
13
+ fix: 增加 server hook API
14
+ - Updated dependencies [c0d8dac]
15
+ - Updated dependencies [8658a78]
16
+ - Updated dependencies [05d4a4f]
17
+ - Updated dependencies [7bfaaf9]
18
+ - Updated dependencies [b1f7000]
19
+ - Updated dependencies [ad05af9]
20
+ - Updated dependencies [5d53d1c]
21
+ - Updated dependencies [37cd159]
22
+ - @modern-js/bff-core@1.15.0
23
+ - @modern-js/utils@1.15.0
24
+ - @modern-js/types@1.15.0
25
+ - @modern-js/bff-runtime@1.15.0
26
+
3
27
  ## 1.7.2
4
28
 
5
29
  ### Patch Changes
@@ -1,6 +1,6 @@
1
1
  import * as path from 'path';
2
2
  import { createRuntimeExportsUtils } from '@modern-js/utils';
3
- import { getRelativeRuntimePath } from '@modern-js/adapter-helpers';
3
+ import { getRelativeRuntimePath } from '@modern-js/bff-core';
4
4
  export default (() => ({
5
5
  name: '@modern-js/plugin-express',
6
6
  setup: api => {
@@ -39,25 +39,13 @@ export default (() => ({
39
39
  },
40
40
 
41
41
  addRuntimeExports(input) {
42
- const {
43
- appDirectory
44
- } = useAppContext();
45
-
46
- const runtimePath = require.resolve(`@modern-js/runtime`, {
47
- paths: [appDirectory]
48
- });
49
-
50
42
  const currentFile = bffExportsUtils.getPath();
51
- const runtimeDir = path.dirname(runtimePath);
52
- const relativeBffPath = path.relative(path.dirname(currentFile), path.join(runtimeDir, './exports/server'));
53
43
  const relativeRuntimeModulePath = path.relative(path.dirname(currentFile), runtimeModulePath);
54
44
  const relativeFramePath = path.relative(path.dirname(currentFile), require.resolve('express'));
55
- bffExportsUtils.addExport(`const bffRuntime = require('${relativeBffPath}');
56
- const pluginRuntime = require('${relativeRuntimeModulePath}');
45
+ bffExportsUtils.addExport(`const pluginRuntime = require('${relativeRuntimeModulePath}');
57
46
  const express = require('${relativeFramePath}')
58
47
  module.exports = {
59
48
  express: express,
60
- ...bffRuntime,
61
49
  ...pluginRuntime
62
50
  }
63
51
  `);
@@ -1,4 +1,4 @@
1
- import { createStorage } from '@modern-js/adapter-helpers';
1
+ import { createStorage } from '@modern-js/bff-core';
2
2
  const {
3
3
  run,
4
4
  useContext
@@ -0,0 +1 @@
1
+ export const hook = attacher => attacher;
@@ -1,3 +1,4 @@
1
1
  export * from '@modern-js/bff-core';
2
2
  export { useContext } from "../context";
3
+ export { hook } from "./hook";
3
4
  export * from "./operators";
@@ -9,7 +9,7 @@ var path = _interopRequireWildcard(require("path"));
9
9
 
10
10
  var _utils = require("@modern-js/utils");
11
11
 
12
- var _adapterHelpers = require("@modern-js/adapter-helpers");
12
+ var _bffCore = require("@modern-js/bff-core");
13
13
 
14
14
  function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
15
15
 
@@ -31,7 +31,7 @@ var _default = () => ({
31
31
  } = appContext;
32
32
  bffExportsUtils = (0, _utils.createRuntimeExportsUtils)(appContext.internalDirectory, 'server');
33
33
  const serverRuntimePath = bffExportsUtils.getPath();
34
- const relativeRuntimePath = (0, _adapterHelpers.getRelativeRuntimePath)(appDirectory, serverRuntimePath);
34
+ const relativeRuntimePath = (0, _bffCore.getRelativeRuntimePath)(appDirectory, serverRuntimePath);
35
35
 
36
36
  if (process.env.NODE_ENV === 'production') {
37
37
  return {
@@ -53,25 +53,13 @@ var _default = () => ({
53
53
  },
54
54
 
55
55
  addRuntimeExports(input) {
56
- const {
57
- appDirectory
58
- } = useAppContext();
59
-
60
- const runtimePath = require.resolve(`@modern-js/runtime`, {
61
- paths: [appDirectory]
62
- });
63
-
64
56
  const currentFile = bffExportsUtils.getPath();
65
- const runtimeDir = path.dirname(runtimePath);
66
- const relativeBffPath = path.relative(path.dirname(currentFile), path.join(runtimeDir, './exports/server'));
67
57
  const relativeRuntimeModulePath = path.relative(path.dirname(currentFile), runtimeModulePath);
68
58
  const relativeFramePath = path.relative(path.dirname(currentFile), require.resolve('express'));
69
- bffExportsUtils.addExport(`const bffRuntime = require('${relativeBffPath}');
70
- const pluginRuntime = require('${relativeRuntimeModulePath}');
59
+ bffExportsUtils.addExport(`const pluginRuntime = require('${relativeRuntimeModulePath}');
71
60
  const express = require('${relativeFramePath}')
72
61
  module.exports = {
73
62
  express: express,
74
- ...bffRuntime,
75
63
  ...pluginRuntime
76
64
  }
77
65
  `);
@@ -5,11 +5,11 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.useContext = exports.run = void 0;
7
7
 
8
- var _adapterHelpers = require("@modern-js/adapter-helpers");
8
+ var _bffCore = require("@modern-js/bff-core");
9
9
 
10
10
  const {
11
11
  run,
12
12
  useContext
13
- } = (0, _adapterHelpers.createStorage)();
13
+ } = (0, _bffCore.createStorage)();
14
14
  exports.useContext = useContext;
15
15
  exports.run = run;
@@ -0,0 +1,10 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.hook = void 0;
7
+
8
+ const hook = attacher => attacher;
9
+
10
+ exports.hook = hook;
@@ -4,8 +4,15 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  var _exportNames = {
7
- useContext: true
7
+ useContext: true,
8
+ hook: true
8
9
  };
10
+ Object.defineProperty(exports, "hook", {
11
+ enumerable: true,
12
+ get: function () {
13
+ return _hook.hook;
14
+ }
15
+ });
9
16
  Object.defineProperty(exports, "useContext", {
10
17
  enumerable: true,
11
18
  get: function () {
@@ -29,6 +36,8 @@ Object.keys(_bffCore).forEach(function (key) {
29
36
 
30
37
  var _context = require("../context");
31
38
 
39
+ var _hook = require("./hook");
40
+
32
41
  var _operators = require("./operators");
33
42
 
34
43
  Object.keys(_operators).forEach(function (key) {
@@ -0,0 +1,2 @@
1
+ import type { Request, Response, NextFunction } from 'express';
2
+ export declare const hook: (attacher: (req: Request, res: Response, next: NextFunction) => void | Promise<void>) => (req: Request, res: Response, next: NextFunction) => void | Promise<void>;
@@ -1,3 +1,4 @@
1
1
  export * from '@modern-js/bff-core';
2
2
  export { useContext } from '../context';
3
+ export { hook } from './hook';
3
4
  export * from './operators';
package/package.json CHANGED
@@ -11,7 +11,7 @@
11
11
  "modern",
12
12
  "modern.js"
13
13
  ],
14
- "version": "1.7.3-beta.0",
14
+ "version": "1.15.0",
15
15
  "jsnext:source": "./src/index.ts",
16
16
  "types": "./dist/types/index.d.ts",
17
17
  "main": "./dist/js/node/index.js",
@@ -34,11 +34,10 @@
34
34
  },
35
35
  "dependencies": {
36
36
  "@babel/runtime": "^7.18.0",
37
- "@modern-js/adapter-helpers": "^1.3.0",
38
- "@modern-js/bff-core": "^1.2.2",
39
- "@modern-js/bff-runtime": "^1.4.0",
40
- "@modern-js/types": "^1.6.2",
41
- "@modern-js/utils": "^1.9.0",
37
+ "@modern-js/bff-core": "1.15.0",
38
+ "@modern-js/bff-runtime": "1.15.0",
39
+ "@modern-js/types": "1.15.0",
40
+ "@modern-js/utils": "1.15.0",
42
41
  "cookie-parser": "^1.4.5",
43
42
  "finalhandler": "^1.1.2",
44
43
  "formidable": "^1.2.2",
@@ -46,10 +45,10 @@
46
45
  "type-is": "^1.6.18"
47
46
  },
48
47
  "devDependencies": {
49
- "@modern-js/core": "1.14.0",
50
- "@modern-js/server-core": "1.4.1",
51
- "@scripts/build": "0.0.0",
52
- "@scripts/jest-config": "0.0.0",
48
+ "@modern-js/core": "1.15.0",
49
+ "@modern-js/server-core": "1.15.0",
50
+ "@scripts/build": "1.15.0",
51
+ "@scripts/jest-config": "1.15.0",
53
52
  "@types/cookie-parser": "^1.4.2",
54
53
  "@types/express": "^4.17.13",
55
54
  "@types/finalhandler": "^1.1.1",
@@ -74,8 +73,7 @@
74
73
  },
75
74
  "publishConfig": {
76
75
  "registry": "https://registry.npmjs.org/",
77
- "access": "public",
78
- "types": "./dist/types/index.d.ts"
76
+ "access": "public"
79
77
  },
80
78
  "wireit": {
81
79
  "build": {
package/types.d.ts CHANGED
@@ -19,6 +19,4 @@ declare module '@modern-js/runtime/server' {
19
19
  export function hook(attacher: ExpressAttacher): ExpressAttacher;
20
20
 
21
21
  export * from '@modern-js/bff-core';
22
-
23
- export * from '@modern-js/bff-runtime';
24
22
  }