minimonolith 0.25.24 → 0.26.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 +55 -81
- package/backtest/back.js +54 -0
- package/backtest/backtest.js +131 -0
- package/backtest/handler.js +23 -0
- package/backtest/handlerCompiletimeError.js +10 -0
- package/backtest/handlerCompiletimeError2.js +10 -0
- package/backtest/handlerRuntimeError.js +24 -0
- package/backtest/localDocker/Dockerfile +11 -0
- package/backtest/localDocker/docker-compose.yml +34 -0
- package/backtest/localDocker/run.sh +4 -0
- package/backtest/localDocker/shutdown.sh +2 -0
- package/backtest/localDocker/update.sh +2 -0
- package/backtest/server.js +7 -0
- package/backtest/todo/delete/index.js +7 -0
- package/backtest/todo/delete/valid.js +8 -0
- package/backtest/todo/get/index.js +3 -0
- package/backtest/todo/getAttributes/index.js +5 -0
- package/backtest/todo/getAttributes/valid.js +5 -0
- package/backtest/todo/getOne/index.js +3 -0
- package/backtest/todo/getOne/valid.js +8 -0
- package/backtest/todo/getOneAlias/index.js +3 -0
- package/backtest/todo/getOneAlias/valid.js +3 -0
- package/backtest/todo/index.js +1 -0
- package/backtest/todo/model.js +19 -0
- package/backtest/todo/patch/index.js +6 -0
- package/backtest/todo/patch/valid.js +12 -0
- package/backtest/todo/post/index.js +5 -0
- package/backtest/todo/post/valid.js +5 -0
- package/backtest/todo/postSeed/index.js +9 -0
- package/backtest/todo/postSeed/seed.js +4 -0
- package/backtest/todoCompiletimeError/got/index.js +1 -0
- package/backtest/todoCompiletimeError/index.js +1 -0
- package/backtest/todoList/delete/handler.js +7 -0
- package/backtest/todoList/delete/valid.js +5 -0
- package/backtest/todoList/get/handler.js +5 -0
- package/backtest/todoList/index.js +1 -0
- package/backtest/todoList/model.js +17 -0
- package/backtest/todoList/post/handler.js +9 -0
- package/backtest/todoList/post/valid.js +6 -0
- package/backtest/todoRuntimeError/get/index.js +1 -0
- package/index.js +13 -22
- package/package.json +7 -8
- package/src/api/get/index.js +17 -0
- package/src/api/getNewAPI/index.js +11 -0
- package/src/api/getSyncedHandler/index.js +23 -0
- package/src/api/index.js +4 -0
- package/src/api/postService/index.js +29 -0
- package/src/autotest/getMethodTest/back.index.js +29 -0
- package/{autotest/getMethodTest/handler.js → src/autotest/getMethodTest/index.js} +1 -3
- package/src/autotest/index.js +3 -0
- package/src/database/index.js +4 -0
- package/src/database/post/index.js +38 -0
- package/src/database/postConnection/index.js +25 -0
- package/src/error/index.js +4 -0
- package/src/error/postCompiletime/index.js +13 -0
- package/src/error/postRuntime/index.js +7 -0
- package/src/event/getParsedEvent/index.js +9 -0
- package/src/event/index.js +3 -0
- package/src/log/index.js +5 -0
- package/src/log/post/index.js +3 -0
- package/src/log/postERROR/index.js +3 -0
- package/src/log/postINFO/index.js +3 -0
- package/src/method/getParsedCode/index.js +13 -0
- package/{service/getResponseCode/handler.js → src/method/getResponseCode/index.js} +1 -3
- package/src/method/getRouteCode/index.js +12 -0
- package/src/method/getType/index.js +9 -0
- package/src/method/index.js +7 -0
- package/src/method/post/index.js +44 -0
- package/src/method/postResponse/index.js +29 -0
- package/src/middleware/index.js +4 -0
- package/src/middleware/postCors/index.js +20 -0
- package/src/middleware/postError/index.js +10 -0
- package/src/model/getSynced/index.js +23 -0
- package/src/model/index.js +4 -0
- package/src/model/post/index.js +16 -0
- package/{server → src/server}/getNodejsServerHandler/index.js +13 -7
- package/src/server/getServerFactory/index.js +12 -0
- package/src/server/index.js +3 -0
- package/api/api.js +0 -5
- package/api/getModels/handler.js +0 -5
- package/api/getModels/out.js +0 -3
- package/api/getNewAPI/handler.js +0 -46
- package/api/getNewAPI/in.js +0 -8
- package/api/getNewAPI/out.js +0 -3
- package/api/getORM/handler.js +0 -5
- package/api/getORM/out.js +0 -3
- package/api/getSchemas/handler.js +0 -5
- package/api/getSchemas/out.js +0 -3
- package/api/getService/handler.js +0 -8
- package/api/getService/in.js +0 -6
- package/api/getService/out.js +0 -3
- package/api/getServices/handler.js +0 -5
- package/api/getServices/out.js +0 -3
- package/api/getSyncedHandler/handler.js +0 -28
- package/api/getSyncedHandler/in.js +0 -3
- package/api/getSyncedHandler/out.js +0 -3
- package/api/postDebug/handler.js +0 -5
- package/api/postDebug/in.js +0 -3
- package/api/postError/handler.js +0 -5
- package/api/postError/in.js +0 -3
- package/api/postInfo/handler.js +0 -5
- package/api/postInfo/in.js +0 -3
- package/api/postModel/handler.js +0 -8
- package/api/postModel/in.js +0 -6
- package/api/postModule/handler.js +0 -31
- package/api/postModule/in.js +0 -7
- package/api/postORM/handler.js +0 -7
- package/api/postORM/in.js +0 -5
- package/api/postRawModule/handler.js +0 -9
- package/api/postRawModule/in.js +0 -9
- package/api/postRoute/handler.js +0 -9
- package/api/postRoute/in.js +0 -7
- package/api/postSchema/handler.js +0 -8
- package/api/postSchema/in.js +0 -6
- package/api/services.js +0 -18
- package/autotest/getMethodTest/in.js +0 -3
- package/autotest/getMethodTest/out.js +0 -3
- package/autotest/services.js +0 -1
- package/control/get/handler.js +0 -8
- package/control/get/in.js +0 -6
- package/control/get/out.js +0 -3
- package/database/post/handler.js +0 -24
- package/database/post/in.js +0 -12
- package/database/postConnection/handler.js +0 -25
- package/database/postConnection/in.js +0 -5
- package/database/postConnection/out.js +0 -3
- package/database/services.js +0 -1
- package/environment/getDBEnvVars/handler.js +0 -6
- package/environment/getDBEnvVars/in.js +0 -3
- package/environment/getDBEnvVars/out.js +0 -3
- package/environment/getENVEnvVars/handler.js +0 -7
- package/environment/getENVEnvVars/in.js +0 -3
- package/environment/getENVEnvVars/out.js +0 -3
- package/environment/postEnvFile/handler.js +0 -16
- package/environment/postEnvFile/in.js +0 -6
- package/environment/postTestEnvironment/index.js +0 -6
- package/environment/services.js +0 -5
- package/health/post/handler.js +0 -11
- package/health/services.js +0 -1
- package/model/getSynced/handler.js +0 -29
- package/model/post/handler.js +0 -14
- package/model/post/in.js +0 -6
- package/model/services.js +0 -1
- package/modules.js +0 -19
- package/server/getServerFactory/handler.js +0 -17
- package/server/getServerFactory/in.js +0 -8
- package/server/getServerFactory/out.js +0 -3
- package/server/services.js +0 -1
- package/service/getParsedCode/handler.js +0 -19
- package/service/getParsedCode/in.js +0 -6
- package/service/getParsedCode/out.js +0 -6
- package/service/getParsedEvent/handler.js +0 -12
- package/service/getParsedEvent/in.js +0 -5
- package/service/getParsedEvent/out.js +0 -6
- package/service/getResponseCode/in.js +0 -3
- package/service/getResponseCode/out.js +0 -3
- package/service/getRouteCode/handler.js +0 -15
- package/service/getRouteCode/in.js +0 -6
- package/service/getRouteCode/out.js +0 -3
- package/service/getType/handler.js +0 -11
- package/service/getType/in.js +0 -5
- package/service/getType/out.js +0 -3
- package/service/postRoute/handler.js +0 -105
- package/service/postRoute/in.js +0 -6
- package/service/services.js +0 -9
- package/setupTesting.js +0 -17
- package/validation/getParsedAsync/handler.js +0 -37
- package/validation/getParsedAsync/in.js +0 -9
- package/validation/getParsedAsync/out.js +0 -6
- package/validation/services.js +0 -1
- package/zdb/components.js +0 -1
- package/zdb/getAssertExists/handler.js +0 -16
- package/zdb/getAssertExists/in.js +0 -6
- package/zdb/getAssertExists/out.js +0 -3
- package/zdb/getAssertNotExists/handler.js +0 -16
- package/zdb/getAssertNotExists/in.js +0 -6
- package/zdb/getAssertNotExists/out.js +0 -3
- package/zdb/getAssertSafeInt/handler.js +0 -15
- package/zdb/getAssertSafeInt/in.js +0 -6
- package/zdb/getAssertSafeInt/out.js +0 -3
- /package/{control/services.js → backtest/todoRuntimeError/index.js} +0 -0
- /package/{autotest → src/autotest}/getTestServerResponse/index.js +0 -0
- /package/{api → src/middleware/postCors}/corsHeaders.js +0 -0
|
@@ -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
|
|
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
|
|
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
|
-
|
|
63
|
-
|
|
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
|
+
}
|
package/api/api.js
DELETED
package/api/getModels/handler.js
DELETED
package/api/getModels/out.js
DELETED
package/api/getNewAPI/handler.js
DELETED
|
@@ -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
|
-
};
|
package/api/getNewAPI/in.js
DELETED
package/api/getNewAPI/out.js
DELETED
package/api/getORM/handler.js
DELETED
package/api/getORM/out.js
DELETED
package/api/getSchemas/out.js
DELETED
package/api/getService/in.js
DELETED
package/api/getService/out.js
DELETED
package/api/getServices/out.js
DELETED
|
@@ -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
|
-
};
|
package/api/postDebug/handler.js
DELETED
package/api/postDebug/in.js
DELETED
package/api/postError/handler.js
DELETED
package/api/postError/in.js
DELETED
package/api/postInfo/handler.js
DELETED
package/api/postInfo/in.js
DELETED
package/api/postModel/handler.js
DELETED
package/api/postModel/in.js
DELETED
|
@@ -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
|
-
};
|
package/api/postModule/in.js
DELETED
package/api/postORM/handler.js
DELETED
package/api/postORM/in.js
DELETED
package/api/postRawModule/in.js
DELETED
package/api/postRoute/handler.js
DELETED
package/api/postRoute/in.js
DELETED
package/api/postSchema/in.js
DELETED
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
|
-
];
|
package/autotest/services.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export default ['getMethodTest'];
|
package/control/get/handler.js
DELETED
package/control/get/in.js
DELETED
package/control/get/out.js
DELETED
package/database/post/handler.js
DELETED
|
@@ -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
|
-
};
|
package/database/post/in.js
DELETED
|
@@ -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
|
-
};
|
package/database/services.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export default ['post', 'postConnection'];
|
|
@@ -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
|
-
};
|