@modern-js/plugin-koa 1.4.1 → 1.4.4
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 +35 -0
- package/dist/js/modern/cli/index.js +47 -44
- package/dist/js/modern/plugin.js +85 -82
- package/dist/js/modern/registerRoutes.js +2 -26
- package/dist/js/node/cli/index.js +46 -44
- package/dist/js/node/plugin.js +84 -82
- package/dist/js/node/registerRoutes.js +2 -27
- package/dist/types/cli/index.d.ts +3 -18
- package/dist/types/plugin.d.ts +2 -1
- package/package.json +11 -17
- package/tests/fixtures/function-mode/api/upload.ts +4 -0
- package/tests/fixtures/lambda-mode/api/lambda/upload.ts +4 -0
- package/tests/functionMode.test.ts +16 -0
- package/tests/lambdaMode.test.ts +28 -11
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,40 @@
|
|
|
1
1
|
# @modern-js/plugin-koa
|
|
2
2
|
|
|
3
|
+
## 1.4.4
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 952432ac: fix: upload files
|
|
8
|
+
- c1b8fa0a: feat: convert to new server plugin
|
|
9
|
+
- Updated dependencies [c2046f37]
|
|
10
|
+
- @modern-js/utils@1.3.6
|
|
11
|
+
|
|
12
|
+
## 1.4.3
|
|
13
|
+
|
|
14
|
+
### Patch Changes
|
|
15
|
+
|
|
16
|
+
- ef7b0a54: feat: convert to new plugin
|
|
17
|
+
- Updated dependencies [5bf5868d]
|
|
18
|
+
- Updated dependencies [d95f28c3]
|
|
19
|
+
- Updated dependencies [2e8dec93]
|
|
20
|
+
- Updated dependencies [2008fdbd]
|
|
21
|
+
- Updated dependencies [2e8dec93]
|
|
22
|
+
- @modern-js/utils@1.3.5
|
|
23
|
+
- @modern-js/server-core@1.2.3
|
|
24
|
+
|
|
25
|
+
## 1.4.2
|
|
26
|
+
|
|
27
|
+
### Patch Changes
|
|
28
|
+
|
|
29
|
+
- 3eee457b: fix: move some peerDependencies to dependecies
|
|
30
|
+
- Updated dependencies [cc5e8001]
|
|
31
|
+
- Updated dependencies [2520ea86]
|
|
32
|
+
- Updated dependencies [db43dce6]
|
|
33
|
+
- Updated dependencies [e81fd9b7]
|
|
34
|
+
- Updated dependencies [1c411e71]
|
|
35
|
+
- @modern-js/core@1.4.6
|
|
36
|
+
- @modern-js/utils@1.3.4
|
|
37
|
+
|
|
3
38
|
## 1.4.1
|
|
4
39
|
|
|
5
40
|
### Patch Changes
|
|
@@ -1,50 +1,54 @@
|
|
|
1
1
|
import * as path from 'path';
|
|
2
|
-
import { useAppContext, createPlugin } from '@modern-js/core';
|
|
3
2
|
import { createRuntimeExportsUtils } from '@modern-js/utils';
|
|
4
|
-
export default
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
3
|
+
export default (() => ({
|
|
4
|
+
name: '@modern-js/plugin-koa',
|
|
5
|
+
setup: api => {
|
|
6
|
+
let bffExportsUtils;
|
|
7
|
+
const {
|
|
8
|
+
useAppContext
|
|
9
|
+
} = api;
|
|
10
|
+
const runtimeModulePath = path.resolve(__dirname, '../runtime');
|
|
11
|
+
return {
|
|
12
|
+
config() {
|
|
13
|
+
// eslint-disable-next-line react-hooks/rules-of-hooks
|
|
14
|
+
const appContext = useAppContext();
|
|
15
|
+
const {
|
|
16
|
+
appDirectory
|
|
17
|
+
} = appContext;
|
|
18
|
+
bffExportsUtils = createRuntimeExportsUtils(appContext.internalDirectory, 'server');
|
|
19
|
+
const serverRuntimePath = bffExportsUtils.getPath(); // Look up one level, because the artifacts after build have dist directories
|
|
16
20
|
|
|
17
|
-
|
|
21
|
+
let relativeRuntimePath = path.join('../', path.relative(appDirectory, serverRuntimePath));
|
|
18
22
|
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
23
|
+
if (process.env.NODE_ENV === 'development' || process.env.NODE_ENV === 'test') {
|
|
24
|
+
relativeRuntimePath = `./${path.relative(appDirectory, serverRuntimePath)}`;
|
|
25
|
+
}
|
|
22
26
|
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
+
return {
|
|
28
|
+
source: {
|
|
29
|
+
alias: {
|
|
30
|
+
'@modern-js/runtime/server': relativeRuntimePath
|
|
31
|
+
}
|
|
27
32
|
}
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
},
|
|
33
|
+
};
|
|
34
|
+
},
|
|
31
35
|
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
36
|
+
addRuntimeExports(input) {
|
|
37
|
+
// eslint-disable-next-line react-hooks/rules-of-hooks
|
|
38
|
+
const {
|
|
39
|
+
appDirectory
|
|
40
|
+
} = useAppContext();
|
|
37
41
|
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
42
|
+
const runtimePath = require.resolve(`@modern-js/runtime`, {
|
|
43
|
+
paths: [appDirectory]
|
|
44
|
+
});
|
|
41
45
|
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
46
|
+
const currentFile = bffExportsUtils.getPath();
|
|
47
|
+
const runtimeDir = path.dirname(runtimePath);
|
|
48
|
+
const relativeBffPath = path.relative(path.dirname(currentFile), path.join(runtimeDir, './exports/server'));
|
|
49
|
+
const relativeRuntimeModulePath = path.relative(path.dirname(currentFile), runtimeModulePath);
|
|
50
|
+
const relativeFramePath = path.relative(path.dirname(currentFile), require.resolve('koa'));
|
|
51
|
+
bffExportsUtils.addExport(`const bffRuntime = require('${relativeBffPath}');
|
|
48
52
|
const pluginRuntime = require('${relativeRuntimeModulePath}');
|
|
49
53
|
const Koa = require('${relativeFramePath}')
|
|
50
54
|
module.exports = {
|
|
@@ -53,10 +57,9 @@ export default createPlugin(() => {
|
|
|
53
57
|
...pluginRuntime
|
|
54
58
|
}
|
|
55
59
|
`);
|
|
56
|
-
|
|
57
|
-
|
|
60
|
+
return input;
|
|
61
|
+
}
|
|
58
62
|
|
|
59
|
-
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
});
|
|
63
|
+
};
|
|
64
|
+
}
|
|
65
|
+
}));
|
package/dist/js/modern/plugin.js
CHANGED
|
@@ -2,7 +2,6 @@ import * as path from 'path';
|
|
|
2
2
|
import Koa from 'koa';
|
|
3
3
|
import Router from 'koa-router';
|
|
4
4
|
import koaBody from 'koa-body';
|
|
5
|
-
import { createPlugin } from '@modern-js/server-core';
|
|
6
5
|
import { requireModule } from '@modern-js/bff-utils';
|
|
7
6
|
import { fs } from '@modern-js/utils';
|
|
8
7
|
import { run } from "./context";
|
|
@@ -28,37 +27,85 @@ const initMiddlewares = (middleware, app) => {
|
|
|
28
27
|
});
|
|
29
28
|
};
|
|
30
29
|
|
|
31
|
-
export default
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
30
|
+
export default (() => ({
|
|
31
|
+
name: '@modern-js/plugin-koa',
|
|
32
|
+
pre: ['@modern-js/plugin-bff'],
|
|
33
|
+
setup: () => ({
|
|
34
|
+
async prepareApiServer({
|
|
35
|
+
pwd,
|
|
36
|
+
mode,
|
|
37
|
+
config,
|
|
38
|
+
prefix
|
|
39
|
+
}) {
|
|
40
|
+
let app;
|
|
41
|
+
const router = new Router();
|
|
42
|
+
const apiDir = path.join(pwd, './api');
|
|
43
|
+
|
|
44
|
+
if (mode === 'framework') {
|
|
45
|
+
app = await findAppModule(apiDir);
|
|
46
|
+
|
|
47
|
+
if (!(app instanceof Koa)) {
|
|
48
|
+
app = new Koa();
|
|
49
|
+
app.use(koaBody({
|
|
50
|
+
multipart: true
|
|
51
|
+
}));
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
if (config) {
|
|
55
|
+
const {
|
|
56
|
+
middleware
|
|
57
|
+
} = config;
|
|
58
|
+
initMiddlewares(middleware, app);
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
app.use(run);
|
|
62
|
+
registerRoutes(router, prefix);
|
|
63
|
+
} else if (mode === 'function') {
|
|
47
64
|
app = new Koa();
|
|
48
|
-
app.use(koaBody(
|
|
49
|
-
|
|
65
|
+
app.use(koaBody({
|
|
66
|
+
multipart: true
|
|
67
|
+
}));
|
|
68
|
+
|
|
69
|
+
if (config) {
|
|
70
|
+
const {
|
|
71
|
+
middleware
|
|
72
|
+
} = config;
|
|
73
|
+
initMiddlewares(middleware, app);
|
|
74
|
+
}
|
|
50
75
|
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
initMiddlewares(middleware, app);
|
|
76
|
+
app.use(run);
|
|
77
|
+
registerRoutes(router, prefix);
|
|
78
|
+
} else {
|
|
79
|
+
throw new Error(`mode must be function or framework`);
|
|
56
80
|
}
|
|
57
81
|
|
|
58
|
-
app.use(
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
82
|
+
app.use(router.routes());
|
|
83
|
+
return (req, res) => {
|
|
84
|
+
app.on('error', err => {
|
|
85
|
+
if (err) {
|
|
86
|
+
throw err;
|
|
87
|
+
}
|
|
88
|
+
});
|
|
89
|
+
return Promise.resolve(app.callback()(req, res));
|
|
90
|
+
};
|
|
91
|
+
},
|
|
92
|
+
|
|
93
|
+
prepareWebServer({
|
|
94
|
+
config
|
|
95
|
+
}) {
|
|
96
|
+
const app = new Koa();
|
|
97
|
+
app.use(async (ctx, next) => {
|
|
98
|
+
await next();
|
|
99
|
+
|
|
100
|
+
if (!ctx.body) {
|
|
101
|
+
// restore statusCode
|
|
102
|
+
if (ctx.res.statusCode === 404 && !ctx.response._explicitStatus) {
|
|
103
|
+
ctx.res.statusCode = 200;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
ctx.respond = false;
|
|
107
|
+
}
|
|
108
|
+
});
|
|
62
109
|
app.use(koaBody());
|
|
63
110
|
|
|
64
111
|
if (config) {
|
|
@@ -68,59 +115,15 @@ export default createPlugin(() => ({
|
|
|
68
115
|
initMiddlewares(middleware, app);
|
|
69
116
|
}
|
|
70
117
|
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
118
|
+
return (req, res) => {
|
|
119
|
+
app.on('error', err => {
|
|
120
|
+
if (err) {
|
|
121
|
+
throw err;
|
|
122
|
+
}
|
|
123
|
+
});
|
|
124
|
+
return Promise.resolve(app.callback()(req, res));
|
|
125
|
+
};
|
|
75
126
|
}
|
|
76
127
|
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
app.on('error', err => {
|
|
80
|
-
if (err) {
|
|
81
|
-
throw err;
|
|
82
|
-
}
|
|
83
|
-
});
|
|
84
|
-
return Promise.resolve(app.callback()(req, res));
|
|
85
|
-
};
|
|
86
|
-
},
|
|
87
|
-
|
|
88
|
-
prepareWebServer({
|
|
89
|
-
config
|
|
90
|
-
}) {
|
|
91
|
-
const app = new Koa();
|
|
92
|
-
app.use(async (ctx, next) => {
|
|
93
|
-
await next();
|
|
94
|
-
|
|
95
|
-
if (!ctx.body) {
|
|
96
|
-
// restore statusCode
|
|
97
|
-
if (ctx.res.statusCode === 404 && !ctx.response._explicitStatus) {
|
|
98
|
-
ctx.res.statusCode = 200;
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
ctx.respond = false;
|
|
102
|
-
}
|
|
103
|
-
});
|
|
104
|
-
app.use(koaBody());
|
|
105
|
-
|
|
106
|
-
if (config) {
|
|
107
|
-
const {
|
|
108
|
-
middleware
|
|
109
|
-
} = config;
|
|
110
|
-
initMiddlewares(middleware, app);
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
return (req, res) => {
|
|
114
|
-
app.on('error', err => {
|
|
115
|
-
if (err) {
|
|
116
|
-
throw err;
|
|
117
|
-
}
|
|
118
|
-
});
|
|
119
|
-
return Promise.resolve(app.callback()(req, res));
|
|
120
|
-
};
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
}), {
|
|
124
|
-
name: '@modern-js/plugin-koa',
|
|
125
|
-
pre: ['@modern-js/plugin-bff']
|
|
126
|
-
});
|
|
128
|
+
})
|
|
129
|
+
}));
|
|
@@ -1,13 +1,6 @@
|
|
|
1
|
-
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
2
|
-
|
|
3
|
-
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
4
|
-
|
|
5
|
-
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
6
|
-
|
|
7
1
|
import { HttpMethod, useAPIHandlerInfos } from '@modern-js/bff-utils';
|
|
8
2
|
import { isSchemaHandler } from '@modern-js/bff-runtime';
|
|
9
3
|
import typeIs from 'type-is';
|
|
10
|
-
import formidable from 'formidable';
|
|
11
4
|
import { sortDynamicRoutes } from '@modern-js/adapter-helpers';
|
|
12
5
|
import { createDebugger } from '@modern-js/utils';
|
|
13
6
|
const debug = createDebugger('koa');
|
|
@@ -49,9 +42,7 @@ const registerRoutes = (router, prefix) => {
|
|
|
49
42
|
ctx.body = result.value;
|
|
50
43
|
}
|
|
51
44
|
} else {
|
|
52
|
-
const args = Object.values(input.params).concat(input); // eslint-disable-next-line
|
|
53
|
-
|
|
54
|
-
ctx.type = 'json'; // eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
45
|
+
const args = Object.values(input.params).concat(input); // eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
55
46
|
// @ts-expect-error
|
|
56
47
|
// eslint-disable-next-line require-atomic-updates
|
|
57
48
|
|
|
@@ -85,7 +76,7 @@ const getInputFromRequest = async ctx => {
|
|
|
85
76
|
if (typeIs.is(ctx.request.type, ['application/json'])) {
|
|
86
77
|
draft.data = ctx.request.body;
|
|
87
78
|
} else if (typeIs.is(ctx.request.type, ['multipart/form-data'])) {
|
|
88
|
-
draft.formData =
|
|
79
|
+
draft.formData = ctx.request.files;
|
|
89
80
|
} else if (typeIs.is(ctx.request.type, ['application/x-www-form-urlencoded'])) {
|
|
90
81
|
draft.formUrlencoded = ctx.request.body;
|
|
91
82
|
} else {
|
|
@@ -93,19 +84,4 @@ const getInputFromRequest = async ctx => {
|
|
|
93
84
|
}
|
|
94
85
|
|
|
95
86
|
return draft;
|
|
96
|
-
};
|
|
97
|
-
|
|
98
|
-
const resvoleFormData = ctx => {
|
|
99
|
-
const form = formidable({
|
|
100
|
-
multiples: true
|
|
101
|
-
});
|
|
102
|
-
return new Promise((resolve, reject) => {
|
|
103
|
-
form.parse(ctx.req, (err, fields, files) => {
|
|
104
|
-
if (err) {
|
|
105
|
-
reject(err);
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
resolve(_objectSpread(_objectSpread({}, fields), files));
|
|
109
|
-
});
|
|
110
|
-
});
|
|
111
87
|
};
|
|
@@ -7,58 +7,61 @@ exports.default = void 0;
|
|
|
7
7
|
|
|
8
8
|
var path = _interopRequireWildcard(require("path"));
|
|
9
9
|
|
|
10
|
-
var _core = require("@modern-js/core");
|
|
11
|
-
|
|
12
10
|
var _utils = require("@modern-js/utils");
|
|
13
11
|
|
|
14
12
|
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
13
|
|
|
16
14
|
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
17
15
|
|
|
18
|
-
var _default = (
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
16
|
+
var _default = () => ({
|
|
17
|
+
name: '@modern-js/plugin-koa',
|
|
18
|
+
setup: api => {
|
|
19
|
+
let bffExportsUtils;
|
|
20
|
+
const {
|
|
21
|
+
useAppContext
|
|
22
|
+
} = api;
|
|
23
|
+
const runtimeModulePath = path.resolve(__dirname, '../runtime');
|
|
24
|
+
return {
|
|
25
|
+
config() {
|
|
26
|
+
// eslint-disable-next-line react-hooks/rules-of-hooks
|
|
27
|
+
const appContext = useAppContext();
|
|
28
|
+
const {
|
|
29
|
+
appDirectory
|
|
30
|
+
} = appContext;
|
|
31
|
+
bffExportsUtils = (0, _utils.createRuntimeExportsUtils)(appContext.internalDirectory, 'server');
|
|
32
|
+
const serverRuntimePath = bffExportsUtils.getPath(); // Look up one level, because the artifacts after build have dist directories
|
|
30
33
|
|
|
31
|
-
|
|
34
|
+
let relativeRuntimePath = path.join('../', path.relative(appDirectory, serverRuntimePath));
|
|
32
35
|
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
+
if (process.env.NODE_ENV === 'development' || process.env.NODE_ENV === 'test') {
|
|
37
|
+
relativeRuntimePath = `./${path.relative(appDirectory, serverRuntimePath)}`;
|
|
38
|
+
}
|
|
36
39
|
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
40
|
+
return {
|
|
41
|
+
source: {
|
|
42
|
+
alias: {
|
|
43
|
+
'@modern-js/runtime/server': relativeRuntimePath
|
|
44
|
+
}
|
|
41
45
|
}
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
},
|
|
46
|
+
};
|
|
47
|
+
},
|
|
45
48
|
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
49
|
+
addRuntimeExports(input) {
|
|
50
|
+
// eslint-disable-next-line react-hooks/rules-of-hooks
|
|
51
|
+
const {
|
|
52
|
+
appDirectory
|
|
53
|
+
} = useAppContext();
|
|
51
54
|
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
+
const runtimePath = require.resolve(`@modern-js/runtime`, {
|
|
56
|
+
paths: [appDirectory]
|
|
57
|
+
});
|
|
55
58
|
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
59
|
+
const currentFile = bffExportsUtils.getPath();
|
|
60
|
+
const runtimeDir = path.dirname(runtimePath);
|
|
61
|
+
const relativeBffPath = path.relative(path.dirname(currentFile), path.join(runtimeDir, './exports/server'));
|
|
62
|
+
const relativeRuntimeModulePath = path.relative(path.dirname(currentFile), runtimeModulePath);
|
|
63
|
+
const relativeFramePath = path.relative(path.dirname(currentFile), require.resolve('koa'));
|
|
64
|
+
bffExportsUtils.addExport(`const bffRuntime = require('${relativeBffPath}');
|
|
62
65
|
const pluginRuntime = require('${relativeRuntimeModulePath}');
|
|
63
66
|
const Koa = require('${relativeFramePath}')
|
|
64
67
|
module.exports = {
|
|
@@ -67,12 +70,11 @@ var _default = (0, _core.createPlugin)(() => {
|
|
|
67
70
|
...pluginRuntime
|
|
68
71
|
}
|
|
69
72
|
`);
|
|
70
|
-
|
|
71
|
-
|
|
73
|
+
return input;
|
|
74
|
+
}
|
|
72
75
|
|
|
73
|
-
|
|
74
|
-
}
|
|
75
|
-
name: '@modern-js/plugin-koa'
|
|
76
|
+
};
|
|
77
|
+
}
|
|
76
78
|
});
|
|
77
79
|
|
|
78
80
|
exports.default = _default;
|
package/dist/js/node/plugin.js
CHANGED
|
@@ -13,8 +13,6 @@ var _koaRouter = _interopRequireDefault(require("koa-router"));
|
|
|
13
13
|
|
|
14
14
|
var _koaBody = _interopRequireDefault(require("koa-body"));
|
|
15
15
|
|
|
16
|
-
var _serverCore = require("@modern-js/server-core");
|
|
17
|
-
|
|
18
16
|
var _bffUtils = require("@modern-js/bff-utils");
|
|
19
17
|
|
|
20
18
|
var _utils = require("@modern-js/utils");
|
|
@@ -49,37 +47,85 @@ const initMiddlewares = (middleware, app) => {
|
|
|
49
47
|
});
|
|
50
48
|
};
|
|
51
49
|
|
|
52
|
-
var _default = (
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
50
|
+
var _default = () => ({
|
|
51
|
+
name: '@modern-js/plugin-koa',
|
|
52
|
+
pre: ['@modern-js/plugin-bff'],
|
|
53
|
+
setup: () => ({
|
|
54
|
+
async prepareApiServer({
|
|
55
|
+
pwd,
|
|
56
|
+
mode,
|
|
57
|
+
config,
|
|
58
|
+
prefix
|
|
59
|
+
}) {
|
|
60
|
+
let app;
|
|
61
|
+
const router = new _koaRouter.default();
|
|
62
|
+
const apiDir = path.join(pwd, './api');
|
|
63
|
+
|
|
64
|
+
if (mode === 'framework') {
|
|
65
|
+
app = await findAppModule(apiDir);
|
|
66
|
+
|
|
67
|
+
if (!(app instanceof _koa.default)) {
|
|
68
|
+
app = new _koa.default();
|
|
69
|
+
app.use((0, _koaBody.default)({
|
|
70
|
+
multipart: true
|
|
71
|
+
}));
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
if (config) {
|
|
75
|
+
const {
|
|
76
|
+
middleware
|
|
77
|
+
} = config;
|
|
78
|
+
initMiddlewares(middleware, app);
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
app.use(_context.run);
|
|
82
|
+
(0, _registerRoutes.default)(router, prefix);
|
|
83
|
+
} else if (mode === 'function') {
|
|
68
84
|
app = new _koa.default();
|
|
69
|
-
app.use((0, _koaBody.default)(
|
|
70
|
-
|
|
85
|
+
app.use((0, _koaBody.default)({
|
|
86
|
+
multipart: true
|
|
87
|
+
}));
|
|
88
|
+
|
|
89
|
+
if (config) {
|
|
90
|
+
const {
|
|
91
|
+
middleware
|
|
92
|
+
} = config;
|
|
93
|
+
initMiddlewares(middleware, app);
|
|
94
|
+
}
|
|
71
95
|
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
initMiddlewares(middleware, app);
|
|
96
|
+
app.use(_context.run);
|
|
97
|
+
(0, _registerRoutes.default)(router, prefix);
|
|
98
|
+
} else {
|
|
99
|
+
throw new Error(`mode must be function or framework`);
|
|
77
100
|
}
|
|
78
101
|
|
|
79
|
-
app.use(
|
|
80
|
-
(
|
|
81
|
-
|
|
82
|
-
|
|
102
|
+
app.use(router.routes());
|
|
103
|
+
return (req, res) => {
|
|
104
|
+
app.on('error', err => {
|
|
105
|
+
if (err) {
|
|
106
|
+
throw err;
|
|
107
|
+
}
|
|
108
|
+
});
|
|
109
|
+
return Promise.resolve(app.callback()(req, res));
|
|
110
|
+
};
|
|
111
|
+
},
|
|
112
|
+
|
|
113
|
+
prepareWebServer({
|
|
114
|
+
config
|
|
115
|
+
}) {
|
|
116
|
+
const app = new _koa.default();
|
|
117
|
+
app.use(async (ctx, next) => {
|
|
118
|
+
await next();
|
|
119
|
+
|
|
120
|
+
if (!ctx.body) {
|
|
121
|
+
// restore statusCode
|
|
122
|
+
if (ctx.res.statusCode === 404 && !ctx.response._explicitStatus) {
|
|
123
|
+
ctx.res.statusCode = 200;
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
ctx.respond = false;
|
|
127
|
+
}
|
|
128
|
+
});
|
|
83
129
|
app.use((0, _koaBody.default)());
|
|
84
130
|
|
|
85
131
|
if (config) {
|
|
@@ -89,61 +135,17 @@ var _default = (0, _serverCore.createPlugin)(() => ({
|
|
|
89
135
|
initMiddlewares(middleware, app);
|
|
90
136
|
}
|
|
91
137
|
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
138
|
+
return (req, res) => {
|
|
139
|
+
app.on('error', err => {
|
|
140
|
+
if (err) {
|
|
141
|
+
throw err;
|
|
142
|
+
}
|
|
143
|
+
});
|
|
144
|
+
return Promise.resolve(app.callback()(req, res));
|
|
145
|
+
};
|
|
96
146
|
}
|
|
97
147
|
|
|
98
|
-
|
|
99
|
-
return (req, res) => {
|
|
100
|
-
app.on('error', err => {
|
|
101
|
-
if (err) {
|
|
102
|
-
throw err;
|
|
103
|
-
}
|
|
104
|
-
});
|
|
105
|
-
return Promise.resolve(app.callback()(req, res));
|
|
106
|
-
};
|
|
107
|
-
},
|
|
108
|
-
|
|
109
|
-
prepareWebServer({
|
|
110
|
-
config
|
|
111
|
-
}) {
|
|
112
|
-
const app = new _koa.default();
|
|
113
|
-
app.use(async (ctx, next) => {
|
|
114
|
-
await next();
|
|
115
|
-
|
|
116
|
-
if (!ctx.body) {
|
|
117
|
-
// restore statusCode
|
|
118
|
-
if (ctx.res.statusCode === 404 && !ctx.response._explicitStatus) {
|
|
119
|
-
ctx.res.statusCode = 200;
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
ctx.respond = false;
|
|
123
|
-
}
|
|
124
|
-
});
|
|
125
|
-
app.use((0, _koaBody.default)());
|
|
126
|
-
|
|
127
|
-
if (config) {
|
|
128
|
-
const {
|
|
129
|
-
middleware
|
|
130
|
-
} = config;
|
|
131
|
-
initMiddlewares(middleware, app);
|
|
132
|
-
}
|
|
133
|
-
|
|
134
|
-
return (req, res) => {
|
|
135
|
-
app.on('error', err => {
|
|
136
|
-
if (err) {
|
|
137
|
-
throw err;
|
|
138
|
-
}
|
|
139
|
-
});
|
|
140
|
-
return Promise.resolve(app.callback()(req, res));
|
|
141
|
-
};
|
|
142
|
-
}
|
|
143
|
-
|
|
144
|
-
}), {
|
|
145
|
-
name: '@modern-js/plugin-koa',
|
|
146
|
-
pre: ['@modern-js/plugin-bff']
|
|
148
|
+
})
|
|
147
149
|
});
|
|
148
150
|
|
|
149
151
|
exports.default = _default;
|
|
@@ -11,20 +11,12 @@ var _bffRuntime = require("@modern-js/bff-runtime");
|
|
|
11
11
|
|
|
12
12
|
var _typeIs = _interopRequireDefault(require("type-is"));
|
|
13
13
|
|
|
14
|
-
var _formidable = _interopRequireDefault(require("formidable"));
|
|
15
|
-
|
|
16
14
|
var _adapterHelpers = require("@modern-js/adapter-helpers");
|
|
17
15
|
|
|
18
16
|
var _utils = require("@modern-js/utils");
|
|
19
17
|
|
|
20
18
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
21
19
|
|
|
22
|
-
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
23
|
-
|
|
24
|
-
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
25
|
-
|
|
26
|
-
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
27
|
-
|
|
28
20
|
const debug = (0, _utils.createDebugger)('koa');
|
|
29
21
|
|
|
30
22
|
const registerRoutes = (router, prefix) => {
|
|
@@ -64,9 +56,7 @@ const registerRoutes = (router, prefix) => {
|
|
|
64
56
|
ctx.body = result.value;
|
|
65
57
|
}
|
|
66
58
|
} else {
|
|
67
|
-
const args = Object.values(input.params).concat(input); // eslint-disable-next-line
|
|
68
|
-
|
|
69
|
-
ctx.type = 'json'; // eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
59
|
+
const args = Object.values(input.params).concat(input); // eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
70
60
|
// @ts-expect-error
|
|
71
61
|
// eslint-disable-next-line require-atomic-updates
|
|
72
62
|
|
|
@@ -101,7 +91,7 @@ const getInputFromRequest = async ctx => {
|
|
|
101
91
|
if (_typeIs.default.is(ctx.request.type, ['application/json'])) {
|
|
102
92
|
draft.data = ctx.request.body;
|
|
103
93
|
} else if (_typeIs.default.is(ctx.request.type, ['multipart/form-data'])) {
|
|
104
|
-
draft.formData =
|
|
94
|
+
draft.formData = ctx.request.files;
|
|
105
95
|
} else if (_typeIs.default.is(ctx.request.type, ['application/x-www-form-urlencoded'])) {
|
|
106
96
|
draft.formUrlencoded = ctx.request.body;
|
|
107
97
|
} else {
|
|
@@ -109,19 +99,4 @@ const getInputFromRequest = async ctx => {
|
|
|
109
99
|
}
|
|
110
100
|
|
|
111
101
|
return draft;
|
|
112
|
-
};
|
|
113
|
-
|
|
114
|
-
const resvoleFormData = ctx => {
|
|
115
|
-
const form = (0, _formidable.default)({
|
|
116
|
-
multiples: true
|
|
117
|
-
});
|
|
118
|
-
return new Promise((resolve, reject) => {
|
|
119
|
-
form.parse(ctx.req, (err, fields, files) => {
|
|
120
|
-
if (err) {
|
|
121
|
-
reject(err);
|
|
122
|
-
}
|
|
123
|
-
|
|
124
|
-
resolve(_objectSpread(_objectSpread({}, fields), files));
|
|
125
|
-
});
|
|
126
|
-
});
|
|
127
102
|
};
|
|
@@ -1,20 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
resolved: import("@modern-js/core").NormalizedConfig;
|
|
5
|
-
}>;
|
|
6
|
-
validateSchema: import("@modern-js/core").ParallelWorkflow<void, unknown>;
|
|
7
|
-
prepare: import("@modern-js/core").AsyncWorkflow<void, void>;
|
|
8
|
-
commands: import("@modern-js/core").AsyncWorkflow<{
|
|
9
|
-
program: import("commander").Command;
|
|
10
|
-
}, void>;
|
|
11
|
-
watchFiles: import("@modern-js/core").ParallelWorkflow<void, unknown>;
|
|
12
|
-
fileChange: import("@modern-js/core").AsyncWorkflow<{
|
|
13
|
-
filename: string;
|
|
14
|
-
eventType: "add" | "unlink" | "change";
|
|
15
|
-
}, void>;
|
|
16
|
-
beforeExit: import("@modern-js/core").AsyncWorkflow<void, void>;
|
|
17
|
-
beforeRestart: import("@modern-js/core").AsyncWorkflow<void, void>;
|
|
18
|
-
} & import("@modern-js/core").ClearDraftProgress<import("@modern-js/core").Hooks>>>>;
|
|
1
|
+
import type { CliPlugin } from '@modern-js/core';
|
|
2
|
+
|
|
3
|
+
declare const _default: () => CliPlugin;
|
|
19
4
|
|
|
20
5
|
export default _default;
|
package/dist/types/plugin.d.ts
CHANGED
package/package.json
CHANGED
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
"modern",
|
|
12
12
|
"modern.js"
|
|
13
13
|
],
|
|
14
|
-
"version": "1.4.
|
|
14
|
+
"version": "1.4.4",
|
|
15
15
|
"jsnext:source": "./src/index.ts",
|
|
16
16
|
"types": "./dist/types/index.d.ts",
|
|
17
17
|
"main": "./dist/js/node/index.js",
|
|
@@ -35,30 +35,28 @@
|
|
|
35
35
|
"dependencies": {
|
|
36
36
|
"@babel/runtime": "^7.15.3",
|
|
37
37
|
"@modern-js/adapter-helpers": "^1.2.1",
|
|
38
|
-
"@modern-js/
|
|
39
|
-
"
|
|
38
|
+
"@modern-js/bff-runtime": "^1.2.1",
|
|
39
|
+
"@modern-js/bff-utils": "^1.2.2",
|
|
40
|
+
"@modern-js/utils": "^1.3.6",
|
|
40
41
|
"koa-body": "^4.2.0",
|
|
41
42
|
"koa-router": "^10.0.0",
|
|
42
43
|
"type-is": "^1.6.18"
|
|
43
44
|
},
|
|
44
45
|
"devDependencies": {
|
|
45
|
-
"
|
|
46
|
-
"@
|
|
46
|
+
"@scripts/build": "0.0.0",
|
|
47
|
+
"@scripts/jest-config": "0.0.0",
|
|
47
48
|
"@types/jest": "^27.0.1",
|
|
48
49
|
"@types/koa": "^2.13.4",
|
|
49
50
|
"@types/koa-router": "^7.4.4",
|
|
50
51
|
"@types/node": "^14",
|
|
51
52
|
"@types/supertest": "^2.0.11",
|
|
52
53
|
"@types/type-is": "^1.6.3",
|
|
53
|
-
"supertest": "^6.1.6",
|
|
54
|
-
"typescript": "^4",
|
|
55
|
-
"@modern-js/bff-runtime": "^1.2.1",
|
|
56
|
-
"@modern-js/bff-utils": "^1.2.2",
|
|
57
|
-
"@modern-js/core": "^1.4.3",
|
|
58
|
-
"@modern-js/server-core": "^1.2.2",
|
|
59
|
-
"@scripts/build": "0.0.0",
|
|
60
54
|
"jest": "^27",
|
|
61
|
-
"@
|
|
55
|
+
"@modern-js/server-core": "^1.2.4",
|
|
56
|
+
"@modern-js/core": "^1.6.0",
|
|
57
|
+
"supertest": "^6.1.6",
|
|
58
|
+
"koa": "^2.13.3",
|
|
59
|
+
"typescript": "^4"
|
|
62
60
|
},
|
|
63
61
|
"modernConfig": {
|
|
64
62
|
"output": {
|
|
@@ -66,10 +64,6 @@
|
|
|
66
64
|
}
|
|
67
65
|
},
|
|
68
66
|
"peerDependencies": {
|
|
69
|
-
"@modern-js/bff-utils": "^1.2.2",
|
|
70
|
-
"@modern-js/core": "^1.4.3",
|
|
71
|
-
"@modern-js/server-core": "^1.2.2",
|
|
72
|
-
"@modern-js/bff-runtime": "^1.2.1",
|
|
73
67
|
"koa": "^2.13.3"
|
|
74
68
|
},
|
|
75
69
|
"publishConfig": {
|
|
@@ -50,4 +50,20 @@ describe('function-mode', () => {
|
|
|
50
50
|
});
|
|
51
51
|
expect(res3.status).toBe(500);
|
|
52
52
|
});
|
|
53
|
+
|
|
54
|
+
test('should support upload file', done => {
|
|
55
|
+
request(apiHandler)
|
|
56
|
+
.post('/upload')
|
|
57
|
+
.field('my_field', 'value')
|
|
58
|
+
.attach('file', path.join(__dirname, './fixtures/assets/index.html'))
|
|
59
|
+
.end(async (err, res) => {
|
|
60
|
+
if (err) {
|
|
61
|
+
throw err;
|
|
62
|
+
}
|
|
63
|
+
expect(res.statusCode).toBe(200);
|
|
64
|
+
expect(res.body.message).toBe('success');
|
|
65
|
+
expect(res.body.formData).not.toBeUndefined();
|
|
66
|
+
done();
|
|
67
|
+
});
|
|
68
|
+
});
|
|
53
69
|
});
|
package/tests/lambdaMode.test.ts
CHANGED
|
@@ -18,6 +18,7 @@ describe('lambda-mode', () => {
|
|
|
18
18
|
const id = '666';
|
|
19
19
|
const name = 'foo';
|
|
20
20
|
const foo = { id, name };
|
|
21
|
+
const prefix = '/api';
|
|
21
22
|
let apiHandler: any;
|
|
22
23
|
|
|
23
24
|
beforeAll(async () => {
|
|
@@ -28,36 +29,36 @@ describe('lambda-mode', () => {
|
|
|
28
29
|
apiHandler = await runner.prepareApiServer({
|
|
29
30
|
pwd,
|
|
30
31
|
mode: 'framework',
|
|
31
|
-
prefix
|
|
32
|
+
prefix,
|
|
32
33
|
});
|
|
33
34
|
});
|
|
34
35
|
|
|
35
36
|
test('should works', async () => {
|
|
36
|
-
const res = await request(apiHandler).get(
|
|
37
|
+
const res = await request(apiHandler).get(`${prefix}/hello`);
|
|
37
38
|
expect(res.status).toBe(200);
|
|
38
39
|
});
|
|
39
40
|
|
|
40
41
|
test('should works with query', async () => {
|
|
41
|
-
const res = await request(apiHandler).get(
|
|
42
|
+
const res = await request(apiHandler).get(`${prefix}/nest/user?id=${id}`);
|
|
42
43
|
expect(res.status).toBe(200);
|
|
43
44
|
expect(res.body.query.id).toBe(id);
|
|
44
45
|
});
|
|
45
46
|
|
|
46
47
|
test('should works with body', async () => {
|
|
47
|
-
const res = await request(apiHandler).post(
|
|
48
|
+
const res = await request(apiHandler).post(`${prefix}/nest/user`).send(foo);
|
|
48
49
|
expect(res.status).toBe(200);
|
|
49
50
|
expect(res.body.data).toEqual(foo);
|
|
50
51
|
});
|
|
51
52
|
|
|
52
53
|
test('should works with dynamic route ', async () => {
|
|
53
|
-
const res = await request(apiHandler).post(
|
|
54
|
+
const res = await request(apiHandler).post(`${prefix}/nest/${id}`);
|
|
54
55
|
expect(res.status).toBe(200);
|
|
55
56
|
expect(res.body).toEqual({ id });
|
|
56
57
|
});
|
|
57
58
|
|
|
58
59
|
test('should works with context', async () => {
|
|
59
60
|
const res = await request(apiHandler)
|
|
60
|
-
.post(
|
|
61
|
+
.post(`${prefix}/nest/user?id=${id}`)
|
|
61
62
|
.send(foo);
|
|
62
63
|
expect(res.status).toBe(200);
|
|
63
64
|
expect(res.body.data).toEqual(foo);
|
|
@@ -66,7 +67,7 @@ describe('lambda-mode', () => {
|
|
|
66
67
|
|
|
67
68
|
test('should support cookies', async () => {
|
|
68
69
|
const res = await request(apiHandler)
|
|
69
|
-
.post(
|
|
70
|
+
.post(`${prefix}/nest/user?id=${id}`)
|
|
70
71
|
.set('Cookie', [`id=${id};name=${name}`]);
|
|
71
72
|
expect(res.status).toBe(200);
|
|
72
73
|
expect(res.body.cookies.id).toBe(id);
|
|
@@ -74,19 +75,19 @@ describe('lambda-mode', () => {
|
|
|
74
75
|
});
|
|
75
76
|
|
|
76
77
|
test('should works with schema', async () => {
|
|
77
|
-
const res = await request(apiHandler).patch(
|
|
78
|
+
const res = await request(apiHandler).patch(`${prefix}/nest/user`).send({
|
|
78
79
|
id: 777,
|
|
79
80
|
name: 'xxx',
|
|
80
81
|
});
|
|
81
82
|
expect(res.status).toBe(200);
|
|
82
83
|
|
|
83
|
-
const res2 = await request(apiHandler).patch(
|
|
84
|
+
const res2 = await request(apiHandler).patch(`${prefix}/nest/user`).send({
|
|
84
85
|
id: 'aaa',
|
|
85
86
|
name: 'xxx',
|
|
86
87
|
});
|
|
87
88
|
expect(res2.status).toBe(400);
|
|
88
89
|
|
|
89
|
-
const res3 = await request(apiHandler).patch(
|
|
90
|
+
const res3 = await request(apiHandler).patch(`${prefix}/nest/user`).send({
|
|
90
91
|
id: '777',
|
|
91
92
|
name: 'xxx',
|
|
92
93
|
});
|
|
@@ -95,11 +96,27 @@ describe('lambda-mode', () => {
|
|
|
95
96
|
|
|
96
97
|
test('introspection', async () => {
|
|
97
98
|
const res = await request(apiHandler).get(
|
|
98
|
-
|
|
99
|
+
`${prefix}${INTROSPECTION_ROUTE_PATH}`,
|
|
99
100
|
);
|
|
100
101
|
expect(res.status).toBe(200);
|
|
101
102
|
expect(res.body.protocol).toBe('Farrow-API');
|
|
102
103
|
});
|
|
104
|
+
|
|
105
|
+
test('should support upload file', done => {
|
|
106
|
+
request(apiHandler)
|
|
107
|
+
.post(`${prefix}/upload`)
|
|
108
|
+
.field('my_field', 'value')
|
|
109
|
+
.attach('file', path.join(__dirname, './fixtures/assets/index.html'))
|
|
110
|
+
.end(async (err, res) => {
|
|
111
|
+
if (err) {
|
|
112
|
+
throw err;
|
|
113
|
+
}
|
|
114
|
+
expect(res.statusCode).toBe(200);
|
|
115
|
+
expect(res.body.message).toBe('success');
|
|
116
|
+
expect(res.body.formData).not.toBeUndefined();
|
|
117
|
+
done();
|
|
118
|
+
});
|
|
119
|
+
});
|
|
103
120
|
});
|
|
104
121
|
|
|
105
122
|
describe('add middlewares', () => {
|