minimonolith 0.22.1 → 0.22.3
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 +21 -16
- package/package.json +1 -1
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
|
|
@@ -110,13 +115,13 @@ This file validates the `get:id` method's input, ensuring that the provided `id`
|
|
|
110
115
|
|
|
111
116
|
```js
|
|
112
117
|
// todo/get/valid.js
|
|
113
|
-
import { z,
|
|
118
|
+
import { z, zdb } from 'minimonolith';
|
|
114
119
|
|
|
115
120
|
export default ({ MODELS }) => ({
|
|
116
121
|
id: z.string()
|
|
117
|
-
.superRefine(
|
|
122
|
+
.superRefine(zdb.isSafeInt('id'))
|
|
118
123
|
.transform(id => parseInt(id))
|
|
119
|
-
.superRefine(
|
|
124
|
+
.superRefine(zdb.exists(MODELS.todo, 'id')),
|
|
120
125
|
})
|
|
121
126
|
```
|
|
122
127
|
|