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.
Files changed (2) hide show
  1. package/README.md +21 -16
  2. 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 { getServer } from 'minimonolith';
34
+ import { getServerFactory } from 'minimonolith';
35
35
 
36
- const lambdaServer = await getServer(); // loads .env by default, could give '.env.test'
36
+ const getServer = await getServerFactory()(;
37
37
  const { lambdaHandler } = await import('./index.js');
38
38
 
39
- lambdaServer(lambdaHandler, 8080);
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
- // Define environment
53
- const { DEV_ENV, PROD_ENV, TEST_ENV } = process.env;
54
- const API = await getNewAPI({ DEV_ENV, PROD_ENV, TEST_ENV });
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.postCORSService();
59
-
60
- // Database Authentication
61
- const { DB_DIALECT, DB_HOST, DB_DB, DB_USER, DB_PASSWORD, DB_STORAGE } = process.env;
62
- await API.postDatabaseService({ DB_DIALECT, DB_HOST, DB_DB, DB_USER, DB_PASSWORD, DB_STORAGE });
63
-
64
- export const lambdaHandler = await API.getSyncedHandler()
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, DB_VALIDATION } from 'minimonolith';
118
+ import { z, zdb } from 'minimonolith';
114
119
 
115
120
  export default ({ MODELS }) => ({
116
121
  id: z.string()
117
- .superRefine(DB_VALIDATION.isSafeInt('id'))
122
+ .superRefine(zdb.isSafeInt('id'))
118
123
  .transform(id => parseInt(id))
119
- .superRefine(DB_VALIDATION.exists(MODELS.todo, 'id')),
124
+ .superRefine(zdb.exists(MODELS.todo, 'id')),
120
125
  })
121
126
  ```
122
127
 
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "minimonolith",
3
3
  "type": "module",
4
- "version": "0.22.1",
4
+ "version": "0.22.3",
5
5
  "main": "index.js",
6
6
  "license": "MIT",
7
7
  "scripts": {