minimonolith 0.25.23 → 0.26.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.
Files changed (183) hide show
  1. package/README.md +55 -80
  2. package/backtest/back.js +54 -0
  3. package/backtest/backtest.js +131 -0
  4. package/backtest/handler.js +23 -0
  5. package/backtest/handlerCompiletimeError.js +10 -0
  6. package/backtest/handlerCompiletimeError2.js +10 -0
  7. package/backtest/handlerRuntimeError.js +24 -0
  8. package/backtest/localDocker/Dockerfile +11 -0
  9. package/backtest/localDocker/docker-compose.yml +34 -0
  10. package/backtest/localDocker/run.sh +4 -0
  11. package/backtest/localDocker/shutdown.sh +2 -0
  12. package/backtest/localDocker/update.sh +2 -0
  13. package/backtest/server.js +7 -0
  14. package/backtest/todo/delete/index.js +7 -0
  15. package/backtest/todo/delete/valid.js +8 -0
  16. package/backtest/todo/get/index.js +3 -0
  17. package/backtest/todo/getAttributes/index.js +5 -0
  18. package/backtest/todo/getAttributes/valid.js +5 -0
  19. package/backtest/todo/getOne/index.js +3 -0
  20. package/backtest/todo/getOne/valid.js +8 -0
  21. package/backtest/todo/getOneAlias/index.js +3 -0
  22. package/backtest/todo/getOneAlias/valid.js +3 -0
  23. package/backtest/todo/index.js +1 -0
  24. package/backtest/todo/model.js +19 -0
  25. package/backtest/todo/patch/index.js +6 -0
  26. package/backtest/todo/patch/valid.js +12 -0
  27. package/backtest/todo/post/index.js +5 -0
  28. package/backtest/todo/post/valid.js +5 -0
  29. package/backtest/todo/postSeed/index.js +9 -0
  30. package/backtest/todo/postSeed/seed.js +4 -0
  31. package/backtest/todoCompiletimeError/got/index.js +1 -0
  32. package/backtest/todoCompiletimeError/index.js +1 -0
  33. package/backtest/todoList/delete/handler.js +7 -0
  34. package/backtest/todoList/delete/valid.js +5 -0
  35. package/backtest/todoList/get/handler.js +5 -0
  36. package/backtest/todoList/index.js +1 -0
  37. package/backtest/todoList/model.js +17 -0
  38. package/backtest/todoList/post/handler.js +9 -0
  39. package/backtest/todoList/post/valid.js +6 -0
  40. package/backtest/todoRuntimeError/get/index.js +1 -0
  41. package/index.js +13 -22
  42. package/package.json +7 -8
  43. package/src/api/get/index.js +17 -0
  44. package/src/api/getNewAPI/index.js +11 -0
  45. package/src/api/getSyncedHandler/index.js +23 -0
  46. package/src/api/index.js +4 -0
  47. package/src/api/postService/index.js +29 -0
  48. package/src/autotest/getMethodTest/back.index.js +29 -0
  49. package/{autotest/getMethodTest/handler.js → src/autotest/getMethodTest/index.js} +1 -3
  50. package/src/autotest/index.js +3 -0
  51. package/src/database/index.js +4 -0
  52. package/src/database/post/index.js +38 -0
  53. package/src/database/postConnection/index.js +25 -0
  54. package/src/error/index.js +4 -0
  55. package/src/error/postCompiletime/index.js +13 -0
  56. package/src/error/postRuntime/index.js +7 -0
  57. package/src/event/getParsedEvent/index.js +9 -0
  58. package/src/event/index.js +3 -0
  59. package/src/log/index.js +5 -0
  60. package/src/log/post/index.js +3 -0
  61. package/src/log/postERROR/index.js +3 -0
  62. package/src/log/postINFO/index.js +3 -0
  63. package/src/method/getParsedCode/index.js +13 -0
  64. package/{service/getResponseCode/handler.js → src/method/getResponseCode/index.js} +1 -3
  65. package/src/method/getRouteCode/index.js +12 -0
  66. package/src/method/getType/index.js +9 -0
  67. package/src/method/index.js +7 -0
  68. package/src/method/post/index.js +44 -0
  69. package/src/method/postResponse/index.js +29 -0
  70. package/src/middleware/index.js +4 -0
  71. package/src/middleware/postCors/index.js +20 -0
  72. package/src/middleware/postError/index.js +10 -0
  73. package/src/model/getSynced/index.js +23 -0
  74. package/src/model/index.js +4 -0
  75. package/src/model/post/index.js +16 -0
  76. package/{server → src/server}/getNodejsServerHandler/index.js +13 -7
  77. package/src/server/getServerFactory/index.js +12 -0
  78. package/src/server/index.js +3 -0
  79. package/api/api.js +0 -5
  80. package/api/getModels/handler.js +0 -5
  81. package/api/getModels/out.js +0 -3
  82. package/api/getNewAPI/handler.js +0 -46
  83. package/api/getNewAPI/in.js +0 -8
  84. package/api/getNewAPI/out.js +0 -3
  85. package/api/getORM/handler.js +0 -5
  86. package/api/getORM/out.js +0 -3
  87. package/api/getSchemas/handler.js +0 -5
  88. package/api/getSchemas/out.js +0 -3
  89. package/api/getService/handler.js +0 -8
  90. package/api/getService/in.js +0 -6
  91. package/api/getService/out.js +0 -3
  92. package/api/getServices/handler.js +0 -5
  93. package/api/getServices/out.js +0 -3
  94. package/api/getSyncedHandler/handler.js +0 -28
  95. package/api/getSyncedHandler/in.js +0 -3
  96. package/api/getSyncedHandler/out.js +0 -3
  97. package/api/postDebug/handler.js +0 -5
  98. package/api/postDebug/in.js +0 -3
  99. package/api/postError/handler.js +0 -5
  100. package/api/postError/in.js +0 -3
  101. package/api/postInfo/handler.js +0 -5
  102. package/api/postInfo/in.js +0 -3
  103. package/api/postModel/handler.js +0 -8
  104. package/api/postModel/in.js +0 -6
  105. package/api/postModule/handler.js +0 -31
  106. package/api/postModule/in.js +0 -7
  107. package/api/postORM/handler.js +0 -7
  108. package/api/postORM/in.js +0 -5
  109. package/api/postRawModule/handler.js +0 -9
  110. package/api/postRawModule/in.js +0 -9
  111. package/api/postRoute/handler.js +0 -9
  112. package/api/postRoute/in.js +0 -7
  113. package/api/postSchema/handler.js +0 -8
  114. package/api/postSchema/in.js +0 -6
  115. package/api/services.js +0 -18
  116. package/autotest/getMethodTest/in.js +0 -3
  117. package/autotest/getMethodTest/out.js +0 -3
  118. package/autotest/services.js +0 -1
  119. package/control/get/handler.js +0 -8
  120. package/control/get/in.js +0 -6
  121. package/control/get/out.js +0 -3
  122. package/database/post/handler.js +0 -24
  123. package/database/post/in.js +0 -12
  124. package/database/postConnection/handler.js +0 -25
  125. package/database/postConnection/in.js +0 -5
  126. package/database/postConnection/out.js +0 -3
  127. package/database/services.js +0 -1
  128. package/environment/getDBEnvVars/handler.js +0 -6
  129. package/environment/getDBEnvVars/in.js +0 -3
  130. package/environment/getDBEnvVars/out.js +0 -3
  131. package/environment/getENVEnvVars/handler.js +0 -7
  132. package/environment/getENVEnvVars/in.js +0 -3
  133. package/environment/getENVEnvVars/out.js +0 -3
  134. package/environment/postEnvFile/handler.js +0 -16
  135. package/environment/postEnvFile/in.js +0 -6
  136. package/environment/postTestEnvironment/index.js +0 -6
  137. package/environment/services.js +0 -5
  138. package/health/post/handler.js +0 -11
  139. package/health/services.js +0 -1
  140. package/model/getSynced/handler.js +0 -29
  141. package/model/post/handler.js +0 -14
  142. package/model/post/in.js +0 -6
  143. package/model/services.js +0 -1
  144. package/modules.js +0 -19
  145. package/server/getServerFactory/handler.js +0 -17
  146. package/server/getServerFactory/in.js +0 -8
  147. package/server/getServerFactory/out.js +0 -3
  148. package/server/services.js +0 -1
  149. package/service/getParsedCode/handler.js +0 -19
  150. package/service/getParsedCode/in.js +0 -6
  151. package/service/getParsedCode/out.js +0 -6
  152. package/service/getParsedEvent/handler.js +0 -12
  153. package/service/getParsedEvent/in.js +0 -5
  154. package/service/getParsedEvent/out.js +0 -6
  155. package/service/getResponseCode/in.js +0 -3
  156. package/service/getResponseCode/out.js +0 -3
  157. package/service/getRouteCode/handler.js +0 -15
  158. package/service/getRouteCode/in.js +0 -6
  159. package/service/getRouteCode/out.js +0 -3
  160. package/service/getType/handler.js +0 -11
  161. package/service/getType/in.js +0 -5
  162. package/service/getType/out.js +0 -3
  163. package/service/postRoute/handler.js +0 -105
  164. package/service/postRoute/in.js +0 -6
  165. package/service/services.js +0 -9
  166. package/setupTesting.js +0 -17
  167. package/validation/getParsedAsync/handler.js +0 -37
  168. package/validation/getParsedAsync/in.js +0 -9
  169. package/validation/getParsedAsync/out.js +0 -6
  170. package/validation/services.js +0 -1
  171. package/zdb/components.js +0 -1
  172. package/zdb/getAssertExists/handler.js +0 -16
  173. package/zdb/getAssertExists/in.js +0 -6
  174. package/zdb/getAssertExists/out.js +0 -3
  175. package/zdb/getAssertNotExists/handler.js +0 -16
  176. package/zdb/getAssertNotExists/in.js +0 -6
  177. package/zdb/getAssertNotExists/out.js +0 -3
  178. package/zdb/getAssertSafeInt/handler.js +0 -15
  179. package/zdb/getAssertSafeInt/in.js +0 -6
  180. package/zdb/getAssertSafeInt/out.js +0 -3
  181. /package/{control/services.js → backtest/todoRuntimeError/index.js} +0 -0
  182. /package/{autotest → src/autotest}/getTestServerResponse/index.js +0 -0
  183. /package/{api → src/middleware/postCors}/corsHeaders.js +0 -0
@@ -0,0 +1,4 @@
1
+ import getSynced from './getSynced/index.js';
2
+ import post from './post/index.js';
3
+
4
+ export default { getSynced, post };
@@ -0,0 +1,16 @@
1
+ import fs from 'fs';
2
+ import url from 'url';
3
+
4
+ import API_SERVICE from '../../api/index.js';
5
+ import LOG_SERVICE from '../../log/index.js';
6
+ const CYAN = '\x1b[36m', YELLOW = '\x1b[33m', END = '\x1b[0m';
7
+
8
+ export default async (SERVICE_NAME, MODEL) => {
9
+ if (!MODEL) {
10
+ LOG_SERVICE.post(' MODEL_NOT_FOUND')
11
+ return;
12
+ }
13
+
14
+ LOG_SERVICE.post(` + MODEL: ${CYAN}${SERVICE_NAME}${END}`)
15
+ API_SERVICE.get().SCHEMAS[SERVICE_NAME] = MODEL(SERVICE_NAME);
16
+ }
@@ -2,7 +2,9 @@
2
2
 
3
3
  import url from 'url';
4
4
 
5
- import CORS_HEADERS from '../../api/corsHeaders.js';
5
+ import LOG_SERVICE from '../../log/index.js';
6
+
7
+ import CORS_HEADERS from '../../middleware/postCors/corsHeaders.js';
6
8
 
7
9
  const getBody = req => {
8
10
  return new Promise((resolve, reject) => {
@@ -31,8 +33,7 @@ const getLambdaEvent = (req, queryString, jwtClaims, body) => {
31
33
  body,
32
34
  };
33
35
 
34
- if (req.headers['content-type'])
35
- event.headers['Content-Type'] = req.headers['content-type'];
36
+ if (req.headers['content-type']) event.headers['Content-Type'] = req.headers['content-type'];
36
37
  if (req.headers['x-trigger-error']) event.headers['x-trigger-error'] = 'TRUE';
37
38
  if (req.headers.accept) event.headers.accept = req.headers.accept;
38
39
  if (req.headers['user-agent']) event.headers['User-Agent'] = req.headers['user-agent'];
@@ -45,7 +46,9 @@ export default lambdaHandler => async (req, res) => {
45
46
  const authHeader = req.headers.authorization;
46
47
  const jwtClaims = authHeader?.startsWith('Bearer ') ? getJWTClaims(authHeader) : null;
47
48
 
48
- const tempQueryString = url.parse(req.url, true).query;
49
+ //const tempQueryString = url.parse(req.url, true).query;
50
+ const parsedUrl = new URL(req.url, `http://${req.headers.host}`);
51
+ const tempQueryString = Object.fromEntries(parsedUrl.searchParams.entries());
49
52
  const queryString = tempQueryString ? tempQueryString : undefined;
50
53
 
51
54
  const tempBody = await getBody(req);
@@ -53,14 +56,17 @@ export default lambdaHandler => async (req, res) => {
53
56
 
54
57
  const lambdaEvent = getLambdaEvent(req, queryString, jwtClaims, body);
55
58
  const lambdaRes = await lambdaHandler(lambdaEvent, null)
59
+ console.log('lambdaRes', lambdaRes);
56
60
 
57
61
  res.statusCode = lambdaRes.statusCode;
58
- for (let k in CORS_HEADERS) res.setHeader(k, CORS_HEADERS[k]);
62
+ for (let k in lambdaRes.headers) res.setHeader(k, lambdaRes.headers[k]);
63
+ //for (let k in CORS_HEADERS) res.setHeader(k, CORS_HEADERS[k]);
59
64
  res.end(lambdaRes.body);
65
+ console.log('got here');
60
66
 
61
67
  } catch(SERVER_ERROR) {
62
- //LOG_SERVICE.post({ SERVER_ERROR });
63
- console.error({ SERVER_ERROR });
68
+ console.log('got here2');
69
+ LOG_SERVICE.post({ SERVER_ERROR });
64
70
  res.statusCode = 500;
65
71
  for (let k in CORS_HEADERS) res.setHeader(k, CORS_HEADERS[k]);
66
72
  res.end(JSON.stringify({ REQUEST_PARSING_ERROR: SERVER_ERROR.toString() }));
@@ -0,0 +1,12 @@
1
+ import http from 'http';
2
+
3
+ import getNodejsServerHandler from '../getNodejsServerHandler/index.js';
4
+
5
+ export default async () => {
6
+
7
+ return (lambdaHandler) => {
8
+ const serverHandler = getNodejsServerHandler(lambdaHandler);
9
+ const server = http.createServer(serverHandler);
10
+ return server;
11
+ }
12
+ }
@@ -0,0 +1,3 @@
1
+ import getServerFactory from './getServerFactory/index.js';
2
+
3
+ export default { getServerFactory };
package/api/api.js DELETED
@@ -1,5 +0,0 @@
1
- let API = undefined;
2
-
3
- export const setAPI = api => { API = api; };
4
-
5
- export default () => API;
@@ -1,5 +0,0 @@
1
- import API from '../api.js';
2
-
3
- export default () => {
4
- return API().MODELS;
5
- }
@@ -1,3 +0,0 @@
1
- import { z } from '@minimonolith/lib';
2
-
3
- export default () => z.unknown();
@@ -1,46 +0,0 @@
1
- import getLambdaAPI from 'lambda-api';
2
-
3
- import { getNewLib } from '@minimonolith/lib';
4
-
5
- import { setAPI } from '../api.js';
6
-
7
- import CORS_HEADERS from '../corsHeaders.js';
8
-
9
- export default async ({ body, SERVICES }) => {
10
- //const LOG_LEVEL = body.LOG_LEVEL;
11
- const LOG_LEVEL = body;
12
-
13
- const API = {
14
- ROUTES: getLambdaAPI(),
15
- LIB: await getNewLib({ LOG_LEVEL }),
16
- SCHEMAS: {},
17
- MODELS: {},
18
- ORM: undefined,
19
- };
20
-
21
- API.ROUTES.use((req, res, next) => {
22
- if (req.headers['x-trigger-error']) {
23
- const MESSAGE ={
24
- ROUTE_CODE: 'LAMBDA_API',
25
- MESSAGE: 'X_TRIGGER_ERROR_HEADER'
26
- }
27
- API.LIB.error(MESSAGE);
28
- throw new Error(JSON.stringify(MESSAGE));
29
- }
30
- res.cors(); next();
31
- });
32
-
33
- API.ROUTES.options('/*', (req, res) => {
34
- for (let k in CORS_HEADERS) { res.header(k, CORS_HEADERS[k]); }
35
- res.status(200).send({})
36
- });
37
-
38
- API.postHealthService = SERVICES.health.post.handler;
39
- API.postModule = SERVICES.api.postModule.handler;
40
- API.postDatabaseService = SERVICES.database.post.handler;
41
- API.getSyncedHandler = SERVICES.api.getSyncedHandler.handler;
42
-
43
- setAPI(API);
44
-
45
- return API;
46
- };
@@ -1,8 +0,0 @@
1
- import { z } from '@minimonolith/lib';
2
-
3
- export default () => z.number().default(2);
4
- /*
5
- export default () => ({
6
- LOG_LEVEL: z.number().default(2),
7
- });
8
- */
@@ -1,3 +0,0 @@
1
- import { z } from '@minimonolith/lib';
2
-
3
- export default () => z.unknown();
@@ -1,5 +0,0 @@
1
- import API from '../api.js';
2
-
3
- export default () => {
4
- return API().ORM;
5
- }
package/api/getORM/out.js DELETED
@@ -1,3 +0,0 @@
1
- import { z } from '@minimonolith/lib';
2
-
3
- export default () => z.unknown();
@@ -1,5 +0,0 @@
1
- import API from '../api.js';
2
-
3
- export default () => {
4
- return API().SCHEMAS;
5
- }
@@ -1,3 +0,0 @@
1
- import { z } from '@minimonolith/lib';
2
-
3
- export default () => z.unknown();
@@ -1,8 +0,0 @@
1
- import API from '../api.js';
2
-
3
- export default ({ body }) => {
4
- const moduleName = body.moduleName;
5
- const serviceName = body.serviceName;
6
-
7
- return API().LIB.SERVICES[moduleName][serviceName];
8
- }
@@ -1,6 +0,0 @@
1
- import { z } from '@minimonolith/lib';
2
-
3
- export default () => ({
4
- moduleName: z.string(),
5
- serviceName: z.string(),
6
- });
@@ -1,3 +0,0 @@
1
- import { z } from '@minimonolith/lib';
2
-
3
- export default () => z.unknown();
@@ -1,5 +0,0 @@
1
- import API from '../api.js';
2
-
3
- export default ({ body }) => {
4
- return API().LIB.SERVICES;
5
- }
@@ -1,3 +0,0 @@
1
- import { z } from '@minimonolith/lib';
2
-
3
- export default () => z.unknown();
@@ -1,28 +0,0 @@
1
- import getLambdaAPI from 'lambda-api';
2
-
3
- import API from '../api.js';
4
-
5
- export default async ({ body, ROUTE_CODE, SERVICES }) => {
6
-
7
- API().ROUTES.use((err, req, res, next) => {
8
- API().LIB.error({ ROUTE_CODE: 'LAMBDA_API', ERROR: err });
9
- res.cors(); //next();
10
- res.status(500).send({ ROUTE_CODE: 'LAMBDA_API', ERROR: err.message });
11
- });
12
-
13
- if (API().ORM) await SERVICES.model.getSynced.handler();
14
-
15
- API().LIB.postAdditionalKey('MODELS', API().MODELS);
16
-
17
- API().LIB.info({ ROUTE_CODE, INFO: 'LISTENING' });
18
-
19
- return async (event, context) => {
20
- API().LIB.info({
21
- ROUTE_CODE: 'LAMBDA_EVENT',
22
- PATH: event.requestContext?.http?.path,
23
- METHOD: event.requestContext?.http?.method,
24
- });
25
-
26
- return await API().ROUTES.run(event, context);
27
- };
28
- };
@@ -1,3 +0,0 @@
1
- import { z } from '@minimonolith/lib';
2
-
3
- export default () => z.unknown();
@@ -1,3 +0,0 @@
1
- import { z } from '@minimonolith/lib';
2
-
3
- export default () => z.function();
@@ -1,5 +0,0 @@
1
- import API from '../api.js';
2
-
3
- export default ({ body }) => {
4
- API().LIB.debug(body);
5
- }
@@ -1,3 +0,0 @@
1
- import { z } from '@minimonolith/lib';
2
-
3
- export default () => z.unknown();
@@ -1,5 +0,0 @@
1
- import API from '../api.js';
2
-
3
- export default ({ body }) => {
4
- API().LIB.error(body);
5
- }
@@ -1,3 +0,0 @@
1
- import { z } from '@minimonolith/lib';
2
-
3
- export default () => z.unknown();
@@ -1,5 +0,0 @@
1
- import API from '../api.js';
2
-
3
- export default ({ body }) => {
4
- API()?.LIB.info(body);
5
- }
@@ -1,3 +0,0 @@
1
- import { z } from '@minimonolith/lib';
2
-
3
- export default () => z.unknown();
@@ -1,8 +0,0 @@
1
- import API from '../api.js';
2
-
3
- export default ({ body }) => {
4
- const moduleName = body.moduleName;
5
- const model = body.model;
6
-
7
- API().MODELS[moduleName] = model;
8
- }
@@ -1,6 +0,0 @@
1
- import { z } from '@minimonolith/lib';
2
-
3
- export default () => ({
4
- moduleName: z.string(),
5
- model: z.unknown(),
6
- });
@@ -1,31 +0,0 @@
1
- import fs from 'fs';
2
- import url from 'url'
3
- import path from 'path';
4
-
5
- import { PATH_MODULE } from '@minimonolith/lib';
6
-
7
- export default async ({ body, SERVICES }) => {
8
- const moduleName = body.moduleName;
9
- const srcFolder = body.srcFolder;
10
- const modulesFolder = body.modulesFolder;
11
-
12
- const projectRoot = PATH_MODULE.getProjectRoot(
13
- import.meta.url, modulesFolder);
14
- const projectRootPath = projectRoot + path.sep;
15
- const projectRelativeServicePath = path.join('.',
16
- srcFolder, moduleName) + path.sep;
17
- //console.log('postmodule', srcFolder, projectRelativeServicePath);
18
-
19
- await SERVICES.api.postRawModule.handler({
20
- moduleName, srcFolder, modulesFolder });
21
- const moduleURL = new URL(projectRelativeServicePath, projectRootPath);
22
- //console.log('postmodule', moduleURL.href);
23
- await SERVICES.model.post.handler({ moduleName, moduleURL });
24
-
25
- const apiServices = await SERVICES.api.getServices.handler();
26
- for (let serviceName in apiServices[moduleName]) {
27
- const serviceCode = apiServices[moduleName][serviceName].code;
28
- //console.log('POST_ROUTE', moduleName, serviceCode, apiServices);
29
- await SERVICES.service.postRoute.handler({ moduleName, serviceCode });
30
- }
31
- };
@@ -1,7 +0,0 @@
1
- import { z } from '@minimonolith/lib';
2
-
3
- export default () => ({
4
- moduleName: z.string(),
5
- srcFolder: z.string().default(''),
6
- modulesFolder: z.string().default('node_modules'),
7
- });
@@ -1,7 +0,0 @@
1
- import API from '../api.js';
2
-
3
- export default async ({ body }) => {
4
- const ORM = body.ORM;
5
-
6
- API().ORM = ORM;
7
- }
package/api/postORM/in.js DELETED
@@ -1,5 +0,0 @@
1
- import { z } from '@minimonolith/lib';
2
-
3
- export default () => ({
4
- ORM: z.unknown(),
5
- });
@@ -1,9 +0,0 @@
1
- import API from '../api.js';
2
-
3
- export default async ({ body }) => {
4
- const moduleName = body.moduleName;
5
- const srcFolder = body.srcFolder;
6
- const modulesFolder = body.modulesFolder;
7
-
8
- await API().LIB.postModule(moduleName, srcFolder, modulesFolder);
9
- };
@@ -1,9 +0,0 @@
1
- import path from 'path';
2
-
3
- import { z } from '@minimonolith/lib';
4
-
5
- export default () => ({
6
- moduleName: z.string(),
7
- srcFolder: z.string().default(''),
8
- modulesFolder: z.string().default('node_modules' + path.sep),
9
- });
@@ -1,9 +0,0 @@
1
- import API from '../api.js';
2
-
3
- export default ({ body }) => {
4
- const method = body.method;
5
- const route = body.route;
6
- const handler = body.handler;
7
-
8
- API().ROUTES[method](route, handler);
9
- }
@@ -1,7 +0,0 @@
1
- import { z } from '@minimonolith/lib';
2
-
3
- export default () => ({
4
- method: z.string(),
5
- route: z.string(),
6
- handler: z.function(),
7
- })
@@ -1,8 +0,0 @@
1
- import API from '../api.js';
2
-
3
- export default async ({ body }) => {
4
- const moduleName = body.moduleName;
5
- const moduleSchema = body.moduleSchema;
6
-
7
- API().SCHEMAS[moduleName] = moduleSchema;
8
- }
@@ -1,6 +0,0 @@
1
- import { z } from '@minimonolith/lib';
2
-
3
- export default () => ({
4
- moduleName: z.string(),
5
- moduleSchema: z.unknown(),
6
- });
package/api/services.js DELETED
@@ -1,18 +0,0 @@
1
- export default [
2
- 'getNewAPI',
3
- 'getSyncedHandler',
4
- 'postModule',
5
- 'getService',
6
- 'getServices',
7
- 'getORM',
8
- 'getModels',
9
- 'getSchemas',
10
- 'postRoute',
11
- 'postRawModule',
12
- 'postSchema',
13
- 'postORM',
14
- 'postModel',
15
- 'postInfo',
16
- 'postDebug',
17
- 'postError',
18
- ];
@@ -1,3 +0,0 @@
1
- import { z } from '@minimonolith/lib';
2
-
3
- export default () => z.unknown();
@@ -1,3 +0,0 @@
1
- import { z } from '@minimonolith/lib';
2
-
3
- export default () => z.function();
@@ -1 +0,0 @@
1
- export default ['getMethodTest'];
@@ -1,8 +0,0 @@
1
- export default async ({ body }) => {
2
- const SERVICE_NAME = body.SERVICE_NAME;
3
- const MODULE_URL = body.MODULE_URL;
4
-
5
- const handler = (await import(new URL(`${SERVICE_NAME}/index.js`,
6
- MODULE_URL))).default;
7
- return handler;
8
- }
package/control/get/in.js DELETED
@@ -1,6 +0,0 @@
1
- import { z } from '@minimonolith/lib';
2
-
3
- export default () => ({
4
- SERVICE_NAME: z.string(),
5
- MODULE_URL: z.string(),
6
- })
@@ -1,3 +0,0 @@
1
- import { z } from '@minimonolith/lib';
2
-
3
- export default () => z.unknown();
@@ -1,24 +0,0 @@
1
- import Sequelize from 'sequelize';
2
- //import SequelizeDynamo from 'dynamo-sequelize';
3
-
4
- export default async ({ body, SERVICES, ROUTE }) => {
5
- const dialect = body.dialect;
6
- const host = body.host;
7
- const port = body.port;
8
- const user = body.user;
9
- const pass = body.pass;
10
- const db = body.db;
11
- const storage = body.storage;
12
-
13
- const SEQUELIZE_OPTIONS = { dialect, host, port, storage, logging: false };
14
-
15
- //await SERVICES.api.postDebug.handler({
16
- // 'SEQUELIZE_OPTIONS': SEQUELIZE_OPTIONS });
17
-
18
- await SERVICES.api.postDebug.handler({ ROUTE, DB_VARS: {
19
- dialect, host, port, db, user, pass, storage }});
20
-
21
- const ORM = new Sequelize(db, user, pass, SEQUELIZE_OPTIONS);
22
- await SERVICES.api.postORM.handler({ ORM });
23
- await SERVICES.database.postConnection.handler({ ORM });
24
- };
@@ -1,12 +0,0 @@
1
- import { z } from '@minimonolith/lib';
2
-
3
- export default ({ MODELS }) => ({
4
- dialect: z.enum(['sqlite', 'mysql', 'mariadb', 'postgres',
5
- 'mssql', 'snowflake', 'oracle']).default('sqlite'),
6
- host: z.string().optional(),
7
- user: z.string().optional(),
8
- pass: z.string().optional(),
9
- port: z.number().optional(),
10
- db: z.string().optional(),
11
- storage: z.string().default(':memory:'),
12
- });
@@ -1,25 +0,0 @@
1
- export default async ({ body, ROUTE_CODE, SERVICES }) => {
2
- const ORM = body.ORM;
3
-
4
- const MAX_RETRIES = 5, INITIAL_WAIT = 100;
5
- let connectionRetries = 0, waitTime = INITIAL_WAIT;
6
-
7
- while (connectionRetries < MAX_RETRIES) {
8
- try {
9
- await SERVICES.api.postInfo.handler({
10
- ROUTE_CODE, AUTH_INTENT: connectionRetries });
11
- await ORM.authenticate();
12
- break;
13
-
14
- } catch (META_METHOD_ERROR) {
15
- await new Promise(resolve => setTimeout(resolve, waitTime));
16
-
17
- connectionRetries += 1;
18
- const jitter = Math.random() * 0.3 + 0.7;
19
- waitTime = Math.min(2 * waitTime * jitter,
20
- INITIAL_WAIT * Math.pow(2, MAX_RETRIES));
21
- }
22
- }
23
-
24
- return connectionRetries;
25
- };
@@ -1,5 +0,0 @@
1
- import { z } from '@minimonolith/lib';
2
-
3
- export default ({ MODELS }) => ({
4
- ORM: z.unknown(),
5
- });
@@ -1,3 +0,0 @@
1
- import { z } from '@minimonolith/lib';
2
-
3
- export default ({ MODELS }) => z.number();
@@ -1 +0,0 @@
1
- export default ['post', 'postConnection'];
@@ -1,6 +0,0 @@
1
- export default envVars => {
2
- const DB_ENV_VARS = ['DB_DIALECT', 'DB_HOST', 'DB_PORT', 'DB_DB',
3
- 'DB_USER', 'DB_PASS', 'DB_STORAGE'];
4
- return Object.fromEntries(Object.entries(envVars).filter(
5
- ([envVar]) => DB_ENV_VARS.includes(envVar)));
6
- }
@@ -1,3 +0,0 @@
1
- import { z } from '@minimonolith/lib';
2
-
3
- export default () => z.array(z.string());
@@ -1,3 +0,0 @@
1
- import { z } from '@minimonolith/lib';
2
-
3
- export default () => z.unknown();
@@ -1,7 +0,0 @@
1
- export default ({ body }) => {
2
- const envVars = body.envVars;
3
-
4
- const API_ENV_VARS = ['DEV_ENV', 'PROD_ENV', 'TEST_ENV'];
5
- return Object.fromEntries(Object.entries(envVars).filter(
6
- ([envVar]) => API_ENV_VARS.includes(envVar)));
7
- }
@@ -1,3 +0,0 @@
1
- export default () => ({
2
- envVars: z.unknown(),
3
- })
@@ -1,3 +0,0 @@
1
- import { z } from '@minimonolith/lib';
2
-
3
- export default () => z.unknown();
@@ -1,16 +0,0 @@
1
- import path from 'path';
2
- import url from 'url';
3
- import dotenv from 'dotenv';
4
-
5
- import { PATH_MODULE } from '@minimonolith/lib';
6
-
7
- export default async ({ body }) => {
8
- const envFile = body.envFile;
9
- const modulesFolder = body.modulesFolder;
10
-
11
- const projectRootFileUrl = PATH_MODULE.getProjectRoot(
12
- import.meta.url, modulesFolder);
13
- const projectRootPath = url.fileURLToPath(projectRootFileUrl + path.sep);
14
- const envFilePath = path.resolve(projectRootPath, envFile)
15
- dotenv.config({ path: envFilePath });
16
- };
@@ -1,6 +0,0 @@
1
- import { z } from '@minimonolith/lib';
2
-
3
- export default () => ({
4
- envFile: z.string(),
5
- modulesFolder: z.string(),
6
- })