minimonolith 0.22.0 → 0.22.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 +18 -13
- package/package.json +1 -1
- package/src/autotest/getMethodTest/index.js +10 -7
package/README.md
CHANGED
|
@@ -31,12 +31,12 @@ This file is used for local development. It runs a local server using `minimonol
|
|
|
31
31
|
|
|
32
32
|
```js
|
|
33
33
|
// server.js
|
|
34
|
-
import {
|
|
34
|
+
import { getServerFactory } from 'minimonolith';
|
|
35
35
|
|
|
36
|
-
const
|
|
36
|
+
const getServer = await getServerFactory()(;
|
|
37
37
|
const { lambdaHandler } = await import('./index.js');
|
|
38
38
|
|
|
39
|
-
|
|
39
|
+
getServer(lambdaHandler).listen(8080);
|
|
40
40
|
```
|
|
41
41
|
|
|
42
42
|
### index.js
|
|
@@ -49,19 +49,24 @@ This file serves as the root of the code in a deployed AWS Lambda:
|
|
|
49
49
|
|
|
50
50
|
import { getNewAPI } from 'minimonolith';
|
|
51
51
|
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
52
|
+
const API = getNewAPI({
|
|
53
|
+
PROD_ENV: process.env.PROD_ENV,
|
|
54
|
+
DEV_ENV: process.env.DEV_ENV,
|
|
55
|
+
});
|
|
55
56
|
|
|
56
57
|
await API.postHealthService();
|
|
57
58
|
await API.postService('todo');
|
|
58
|
-
await API.
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
59
|
+
await API.postDatabaseService({
|
|
60
|
+
DB_DIALECT: process.env.DB_DIALECT,
|
|
61
|
+
DB_HOST: process.env.DB_HOST,
|
|
62
|
+
DB_PORT: process.env.DB_PORT,
|
|
63
|
+
DB_DB: process.env.DB_DB,
|
|
64
|
+
DB_USER: process.env.DB_USER,
|
|
65
|
+
DB_PASS: process.env.DB_PASS,
|
|
66
|
+
DB_STORAGE: process.env.DB_STORAGE,
|
|
67
|
+
});
|
|
68
|
+
|
|
69
|
+
export const lambdaHandler = await API.getSyncedHandler();
|
|
65
70
|
```
|
|
66
71
|
|
|
67
72
|
### todo/index.js
|
package/package.json
CHANGED
|
@@ -1,9 +1,12 @@
|
|
|
1
|
-
|
|
1
|
+
export default async server => {
|
|
2
|
+
const fetch = (await import('cross-fetch')).default;
|
|
2
3
|
|
|
3
|
-
|
|
4
|
-
const port = server.address().port
|
|
5
|
-
const url = `http://localhost:${port}${path}`;
|
|
4
|
+
return async ({ path, method, expectedCode, headers, body }) => {
|
|
6
5
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
6
|
+
const port = server.address().port
|
|
7
|
+
const url = `http://localhost:${port}${path}`;
|
|
8
|
+
|
|
9
|
+
const response = await fetch(url, { method, headers, body });
|
|
10
|
+
expect(response.status).toBe(expectedCode);
|
|
11
|
+
};
|
|
12
|
+
};
|