@modern-js/plugin-express 1.5.2 → 1.5.5-canary.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,30 @@
1
1
  # @modern-js/plugin-express
2
2
 
3
+ ## 1.5.4
4
+
5
+ ### Patch Changes
6
+
7
+ - d32f35134: chore: add modern/jest/eslint/ts config files to .npmignore
8
+ - Updated dependencies [d32f35134]
9
+ - Updated dependencies [6ae4a34ae]
10
+ - Updated dependencies [b80229c79]
11
+ - Updated dependencies [948cc4436]
12
+ - @modern-js/adapter-helpers@1.2.4
13
+ - @modern-js/bff-runtime@1.2.3
14
+ - @modern-js/bff-utils@1.2.6
15
+ - @modern-js/types@1.5.3
16
+ - @modern-js/utils@1.7.3
17
+
18
+ ## 1.5.3
19
+
20
+ ### Patch Changes
21
+
22
+ - 69a728375: fix: remove exports.jsnext:source after publish
23
+ - Updated dependencies [cd7346b0d]
24
+ - Updated dependencies [69a728375]
25
+ - @modern-js/utils@1.7.2
26
+ - @modern-js/bff-utils@1.2.5
27
+
3
28
  ## 1.5.2
4
29
 
5
30
  ### Patch Changes
@@ -19,13 +19,24 @@ export default (() => ({
19
19
  bffExportsUtils = createRuntimeExportsUtils(appContext.internalDirectory, 'server');
20
20
  const serverRuntimePath = bffExportsUtils.getPath();
21
21
  const relativeRuntimePath = getRelativeRuntimePath(appDirectory, serverRuntimePath);
22
- return {
23
- source: {
24
- alias: {
25
- '@modern-js/runtime/server': relativeRuntimePath
22
+
23
+ if (process.env.NODE_ENV === 'production') {
24
+ return {
25
+ source: {
26
+ alias: {
27
+ '@modern-js/runtime/server': path.join(__dirname, '../runtime')
28
+ }
29
+ }
30
+ };
31
+ } else {
32
+ return {
33
+ source: {
34
+ alias: {
35
+ '@modern-js/runtime/server': serverRuntimePath
36
+ }
26
37
  }
27
- }
28
- };
38
+ };
39
+ }
29
40
  },
30
41
 
31
42
  addRuntimeExports(input) {
@@ -13,7 +13,6 @@ import { createDebugger } from '@modern-js/utils';
13
13
  const debug = createDebugger('express');
14
14
 
15
15
  const registerRoutes = app => {
16
- // eslint-disable-next-line react-hooks/rules-of-hooks
17
16
  const handlerInfos = useAPIHandlerInfos();
18
17
  sortDynamicRoutes(handlerInfos);
19
18
  debug('handlerInfos', handlerInfos);
@@ -23,7 +22,7 @@ const registerRoutes = app => {
23
22
  method,
24
23
  name
25
24
  }) => {
26
- const wrapedHandler = async (req, res, next) => {
25
+ const wrappedHandler = async (req, res, next) => {
27
26
  const input = await getInputFromRequest(req);
28
27
 
29
28
  if (isSchemaHandler(handler)) {
@@ -61,11 +60,11 @@ const registerRoutes = app => {
61
60
  }
62
61
  };
63
62
 
64
- Object.defineProperties(wrapedHandler, Object.getOwnPropertyDescriptors(handler));
63
+ Object.defineProperties(wrappedHandler, Object.getOwnPropertyDescriptors(handler));
65
64
 
66
65
  if (isNormalMethod(method)) {
67
66
  const routeName = method.toLowerCase();
68
- app[routeName](path || name, wrapedHandler);
67
+ app[routeName](path || name, wrappedHandler);
69
68
  } else {
70
69
  throw new Error(`Unknown HTTP Method: ${method}`);
71
70
  }
@@ -87,7 +86,7 @@ const getInputFromRequest = async request => {
87
86
  if (typeIs(request, ['application/json'])) {
88
87
  draft.data = request.body;
89
88
  } else if (typeIs(request, ['multipart/form-data'])) {
90
- draft.formData = await resvoleFormData(request);
89
+ draft.formData = await resolveFormData(request);
91
90
  } else if (typeIs(request, ['application/x-www-form-urlencoded'])) {
92
91
  draft.formUrlencoded = request.body;
93
92
  } else {
@@ -97,7 +96,7 @@ const getInputFromRequest = async request => {
97
96
  return draft;
98
97
  };
99
98
 
100
- const resvoleFormData = request => {
99
+ const resolveFormData = request => {
101
100
  const form = formidable({
102
101
  multiples: true
103
102
  });
@@ -33,13 +33,24 @@ var _default = () => ({
33
33
  bffExportsUtils = (0, _utils.createRuntimeExportsUtils)(appContext.internalDirectory, 'server');
34
34
  const serverRuntimePath = bffExportsUtils.getPath();
35
35
  const relativeRuntimePath = (0, _adapterHelpers.getRelativeRuntimePath)(appDirectory, serverRuntimePath);
36
- return {
37
- source: {
38
- alias: {
39
- '@modern-js/runtime/server': relativeRuntimePath
36
+
37
+ if (process.env.NODE_ENV === 'production') {
38
+ return {
39
+ source: {
40
+ alias: {
41
+ '@modern-js/runtime/server': path.join(__dirname, '../runtime')
42
+ }
43
+ }
44
+ };
45
+ } else {
46
+ return {
47
+ source: {
48
+ alias: {
49
+ '@modern-js/runtime/server': serverRuntimePath
50
+ }
40
51
  }
41
- }
42
- };
52
+ };
53
+ }
43
54
  },
44
55
 
45
56
  addRuntimeExports(input) {
@@ -28,7 +28,6 @@ function _defineProperty(obj, key, value) { if (key in obj) { Object.definePrope
28
28
  const debug = (0, _utils.createDebugger)('express');
29
29
 
30
30
  const registerRoutes = app => {
31
- // eslint-disable-next-line react-hooks/rules-of-hooks
32
31
  const handlerInfos = (0, _bffUtils.useAPIHandlerInfos)();
33
32
  (0, _adapterHelpers.sortDynamicRoutes)(handlerInfos);
34
33
  debug('handlerInfos', handlerInfos);
@@ -38,7 +37,7 @@ const registerRoutes = app => {
38
37
  method,
39
38
  name
40
39
  }) => {
41
- const wrapedHandler = async (req, res, next) => {
40
+ const wrappedHandler = async (req, res, next) => {
42
41
  const input = await getInputFromRequest(req);
43
42
 
44
43
  if ((0, _bffRuntime.isSchemaHandler)(handler)) {
@@ -76,11 +75,11 @@ const registerRoutes = app => {
76
75
  }
77
76
  };
78
77
 
79
- Object.defineProperties(wrapedHandler, Object.getOwnPropertyDescriptors(handler));
78
+ Object.defineProperties(wrappedHandler, Object.getOwnPropertyDescriptors(handler));
80
79
 
81
80
  if (isNormalMethod(method)) {
82
81
  const routeName = method.toLowerCase();
83
- app[routeName](path || name, wrapedHandler);
82
+ app[routeName](path || name, wrappedHandler);
84
83
  } else {
85
84
  throw new Error(`Unknown HTTP Method: ${method}`);
86
85
  }
@@ -103,7 +102,7 @@ const getInputFromRequest = async request => {
103
102
  if ((0, _typeIs.default)(request, ['application/json'])) {
104
103
  draft.data = request.body;
105
104
  } else if ((0, _typeIs.default)(request, ['multipart/form-data'])) {
106
- draft.formData = await resvoleFormData(request);
105
+ draft.formData = await resolveFormData(request);
107
106
  } else if ((0, _typeIs.default)(request, ['application/x-www-form-urlencoded'])) {
108
107
  draft.formUrlencoded = request.body;
109
108
  } else {
@@ -113,7 +112,7 @@ const getInputFromRequest = async request => {
113
112
  return draft;
114
113
  };
115
114
 
116
- const resvoleFormData = request => {
115
+ const resolveFormData = request => {
117
116
  const form = (0, _formidable.default)({
118
117
  multiples: true
119
118
  });
package/package.json CHANGED
@@ -11,7 +11,7 @@
11
11
  "modern",
12
12
  "modern.js"
13
13
  ],
14
- "version": "1.5.2",
14
+ "version": "1.5.5-canary.0",
15
15
  "jsnext:source": "./src/index.ts",
16
16
  "types": "./dist/types/index.d.ts",
17
17
  "main": "./dist/js/node/index.js",
@@ -30,31 +30,35 @@
30
30
  "./cli": {
31
31
  "jsnext:source": "./src/cli/index.ts",
32
32
  "default": "./dist/js/node/cli/index.js"
33
+ },
34
+ "./runtime": {
35
+ "jsnext:source": "./src/runtime.ts",
36
+ "default": "./dist/js/node/runtime.js"
33
37
  }
34
38
  },
35
39
  "dependencies": {
36
40
  "@babel/runtime": "^7.15.3",
37
- "@modern-js/adapter-helpers": "^1.2.3",
38
- "@modern-js/bff-runtime": "^1.2.2",
39
- "@modern-js/bff-utils": "^1.2.4",
40
- "@modern-js/types": "^1.5.1",
41
- "@modern-js/utils": "^1.6.0",
41
+ "@modern-js/adapter-helpers": "^1.2.4",
42
+ "@modern-js/bff-runtime": "^1.2.3",
43
+ "@modern-js/bff-utils": "^1.2.6",
44
+ "@modern-js/types": "^1.5.3",
45
+ "@modern-js/utils": "^1.7.5",
42
46
  "cookie-parser": "^1.4.5",
43
47
  "finalhandler": "^1.1.2",
44
48
  "formidable": "^1.2.2",
45
49
  "type-is": "^1.6.18"
46
50
  },
47
51
  "devDependencies": {
48
- "@modern-js/core": "1.9.0",
49
- "@modern-js/server-core": "1.3.2",
50
- "@modern-js/server-utils": "1.2.4",
52
+ "@modern-js/core": "1.11.0",
53
+ "@modern-js/server-core": "1.3.5",
54
+ "@modern-js/server-utils": "1.2.9",
51
55
  "@scripts/build": "0.0.0",
52
56
  "@scripts/jest-config": "0.0.0",
53
57
  "@types/cookie-parser": "^1.4.2",
54
58
  "@types/express": "^4.17.13",
55
59
  "@types/finalhandler": "^1.1.1",
56
60
  "@types/formidable": "^1.2.3",
57
- "@types/jest": "^27.0.1",
61
+ "@types/jest": "^27",
58
62
  "@types/node": "^14",
59
63
  "@types/supertest": "^2.0.11",
60
64
  "@types/type-is": "^1.6.3",
@@ -73,12 +77,36 @@
73
77
  },
74
78
  "publishConfig": {
75
79
  "registry": "https://registry.npmjs.org/",
76
- "access": "public"
80
+ "access": "public",
81
+ "types": "./dist/types/index.d.ts"
82
+ },
83
+ "wireit": {
84
+ "build": {
85
+ "command": "modern build",
86
+ "files": [
87
+ "src/**/*",
88
+ "tsconfig.json",
89
+ "package.json"
90
+ ],
91
+ "output": [
92
+ "dist/**/*"
93
+ ]
94
+ },
95
+ "test": {
96
+ "command": "jest --passWithNoTests",
97
+ "files": [
98
+ "src/**/*",
99
+ "tsconfig.json",
100
+ "package.json",
101
+ "tests/**/*"
102
+ ],
103
+ "output": []
104
+ }
77
105
  },
78
106
  "scripts": {
79
107
  "new": "modern new",
80
- "build": "modern build",
81
- "test": "jest --passWithNoTests"
108
+ "build": "wireit",
109
+ "test": "wireit"
82
110
  },
83
111
  "readme": "\n<p align=\"center\">\n <a href=\"https://modernjs.dev\" target=\"blank\"><img src=\"https://lf3-static.bytednsdoc.com/obj/eden-cn/ylaelkeh7nuhfnuhf/modernjs-cover.png\" width=\"300\" alt=\"Modern.js Logo\" /></a>\n</p>\n<p align=\"center\">\n现代 Web 工程体系\n <br/>\n <a href=\"https://modernjs.dev\" target=\"blank\">\n modernjs.dev\n </a>\n</p>\n<p align=\"center\">\n The meta-framework suite designed from scratch for frontend-focused modern web development\n</p>\n\n# Introduction\n\n> The doc site ([modernjs.dev](https://modernjs.dev)) and articles are only available in Chinese for now, we are planning to add English versions soon.\n\n- [Modern.js: Hello, World!](https://zhuanlan.zhihu.com/p/426707646)\n\n## Getting Started\n\n- [Quick Start](https://modernjs.dev/docs/start)\n- [Guides](https://modernjs.dev/docs/guides)\n- [API References](https://modernjs.dev/docs/apis)\n\n## Contributing\n\n- [Contributing Guide](https://github.com/modern-js-dev/modern.js/blob/main/CONTRIBUTING.md)\n"
84
112
  }
package/.eslintrc.js DELETED
@@ -1,7 +0,0 @@
1
- module.exports = {
2
- extends: ['@modern-js'],
3
- parserOptions: {
4
- project: require.resolve('./tsconfig.json'),
5
- },
6
- ignorePatterns: ['types.d.ts'],
7
- };
package/jest.config.js DELETED
@@ -1,7 +0,0 @@
1
- const sharedConfig = require('@scripts/jest-config');
2
-
3
- /** @type {import('@jest/types').Config.InitialOptions} */
4
- module.exports = {
5
- ...sharedConfig,
6
- rootDir: __dirname,
7
- };
package/modern.config.js DELETED
@@ -1,2 +0,0 @@
1
- /** @type {import('@modern-js/module-tools').UserConfig} */
2
- module.exports = {};
package/tsconfig.json DELETED
@@ -1,10 +0,0 @@
1
- {
2
- "extends": "@modern-js/tsconfig/base",
3
- "compilerOptions": {
4
- "declaration": false,
5
- "jsx": "preserve",
6
- "baseUrl": "./",
7
- "isolatedModules": true
8
- },
9
- "include": ["src"]
10
- }