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 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
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "minimonolith",
3
3
  "type": "module",
4
- "version": "0.22.0",
4
+ "version": "0.22.2",
5
5
  "main": "index.js",
6
6
  "license": "MIT",
7
7
  "scripts": {
@@ -1,9 +1,12 @@
1
- import fetch from 'cross-fetch';
1
+ export default async server => {
2
+ const fetch = (await import('cross-fetch')).default;
2
3
 
3
- export default server => async ({ path, method, expectedCode, headers, body }) => {
4
- const port = server.address().port
5
- const url = `http://localhost:${port}${path}`;
4
+ return async ({ path, method, expectedCode, headers, body }) => {
6
5
 
7
- const response = await fetch(url, { method, headers, body });
8
- expect(response.status).toBe(expectedCode);
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
+ };