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.
- package/README.md +55 -80
- 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
package/environment/services.js
DELETED
package/health/post/handler.js
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
export default async ({ SERVICES }) => {
|
|
2
|
-
const method = 'get';
|
|
3
|
-
const route = '/';
|
|
4
|
-
const handler = async (req, res) => {
|
|
5
|
-
const SERVICE_RESPONSE = "API_RUNNING";
|
|
6
|
-
await SERVICES.api.postInfo.handler({ SERVICE_RESPONSE });
|
|
7
|
-
return { SERVICE_RESPONSE: "API_RUNNING" };
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
await SERVICES.api.postRoute.handler({ method, route, handler })
|
|
11
|
-
}
|
package/health/services.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export default ['post'];
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
import { DataTypes } from 'sequelize';
|
|
2
|
-
|
|
3
|
-
export default async ({ ROUTE_CODE, SERVICES }) => {
|
|
4
|
-
const SCHEMAS = await SERVICES.api.getSchemas.handler();
|
|
5
|
-
const ORM = await SERVICES.api.getORM.handler();
|
|
6
|
-
|
|
7
|
-
for (const moduleName of Object.keys(SCHEMAS)) {
|
|
8
|
-
await SERVICES.api.postInfo.handler({
|
|
9
|
-
ROUTE_CODE, LOADING: moduleName });
|
|
10
|
-
|
|
11
|
-
const model = SCHEMAS[moduleName](ORM, DataTypes);
|
|
12
|
-
await SERVICES.api.postModel.handler({ moduleName, model });
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
const MODELS = await SERVICES.api.getModels.handler();
|
|
16
|
-
|
|
17
|
-
for (const [moduleName, MODEL] of Object.entries(MODELS)) {
|
|
18
|
-
await SERVICES.api.postInfo.handler({
|
|
19
|
-
ROUTE_CODE, ASSOCIATING: moduleName });
|
|
20
|
-
MODEL.associate(MODELS);
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
await SERVICES.api.postInfo.handler({
|
|
24
|
-
ROUTE_CODE, SYNCING_ORM: 'WAITING_ORM_SYNCING' });
|
|
25
|
-
await ORM.sync({ alter: process.env.DEV_ENV==='TRUE' ? true : false });
|
|
26
|
-
|
|
27
|
-
await SERVICES.api.postInfo.handler({
|
|
28
|
-
ROUTE_CODE, SYNCING_ORM: 'DONE_ORM_SYNCING' });
|
|
29
|
-
};
|
package/model/post/handler.js
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import fs from 'fs';
|
|
2
|
-
import url from 'url';
|
|
3
|
-
|
|
4
|
-
export default async ({ body, SERVICES }) => {
|
|
5
|
-
const moduleName = body.moduleName;
|
|
6
|
-
const moduleURL = body.moduleURL;
|
|
7
|
-
|
|
8
|
-
if (!fs.existsSync(url.fileURLToPath(`${moduleURL}model.js`))) return;
|
|
9
|
-
await SERVICES.api.postInfo.handler(` FOUND_MODEL ${moduleName}`)
|
|
10
|
-
|
|
11
|
-
const moduleSchema =
|
|
12
|
-
(await import(`${moduleURL}model.js`)).default(moduleName);
|
|
13
|
-
await SERVICES.api.postSchema.handler({ moduleName, moduleSchema });
|
|
14
|
-
};
|
package/model/post/in.js
DELETED
package/model/services.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export default ['getSynced', 'post'];
|
package/modules.js
DELETED
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import http from 'http';
|
|
2
|
-
import path from 'path';
|
|
3
|
-
|
|
4
|
-
import getNodejsServerHandler from '../getNodejsServerHandler/index.js';
|
|
5
|
-
|
|
6
|
-
export default async ({ body, SERVICES }) => {
|
|
7
|
-
const envFile = body.envFile;
|
|
8
|
-
const modulesFolder = body.modulesFolder;
|
|
9
|
-
|
|
10
|
-
await SERVICES.environment.postEnvFile.handler({ envFile, modulesFolder });
|
|
11
|
-
|
|
12
|
-
return (lambdaHandler) => {
|
|
13
|
-
const serverHandler = getNodejsServerHandler(lambdaHandler);
|
|
14
|
-
const server = http.createServer(serverHandler);
|
|
15
|
-
return server;
|
|
16
|
-
}
|
|
17
|
-
}
|
package/server/services.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export default ['getServerFactory'];
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
export default ({ body }) => {
|
|
2
|
-
const moduleName = body.moduleName;
|
|
3
|
-
const serviceCode = body.serviceCode;
|
|
4
|
-
|
|
5
|
-
const servicePathParts = serviceCode.split(":");
|
|
6
|
-
const pathParams = servicePathParts.slice(1).map(param => `:${param}`);
|
|
7
|
-
const rawServiceName = servicePathParts[0];
|
|
8
|
-
const serviceName = rawServiceName[0] === '!' ?
|
|
9
|
-
rawServiceName.substring(1) : rawServiceName;
|
|
10
|
-
|
|
11
|
-
const relativeServiceRoute = `${rawServiceName}`+
|
|
12
|
-
`${pathParams.length > 0 ? '/' : ''}${pathParams.join("/")}`;
|
|
13
|
-
|
|
14
|
-
const serviceRoute = relativeServiceRoute[0]==='!' ?
|
|
15
|
-
`/${relativeServiceRoute.substring(1)}/${moduleName}` :
|
|
16
|
-
`/${moduleName}/${relativeServiceRoute}`;
|
|
17
|
-
|
|
18
|
-
return { serviceName, serviceRoute };
|
|
19
|
-
};
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
export default ({ body }) => {
|
|
2
|
-
const event = body.event;
|
|
3
|
-
|
|
4
|
-
const { params, query, requestContext } = event;
|
|
5
|
-
const claims = requestContext.authorizer?.jwt?.claims
|
|
6
|
-
|
|
7
|
-
const tempUnifiedBody = { ...event.body, ...params, ...query };
|
|
8
|
-
const unifiedBody = Object.keys(tempUnifiedBody).length > 0 ?
|
|
9
|
-
tempUnifiedBody : undefined;
|
|
10
|
-
|
|
11
|
-
return { body: unifiedBody, claims };
|
|
12
|
-
}
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
const getUpperSnakeCase = str => {
|
|
2
|
-
return str
|
|
3
|
-
.replace(/([a-z])([A-Z])/g, '$1_$2')
|
|
4
|
-
.replace(/([A-Z])([A-Z][a-z])/g, '$1_$2')
|
|
5
|
-
.toUpperCase();
|
|
6
|
-
}
|
|
7
|
-
|
|
8
|
-
export default ({ body }) => {
|
|
9
|
-
const moduleName = body.moduleName;
|
|
10
|
-
const serviceName = body.serviceName;
|
|
11
|
-
|
|
12
|
-
const snakeModuleName = getUpperSnakeCase(moduleName);
|
|
13
|
-
const snakeServiceName = getUpperSnakeCase(serviceName);
|
|
14
|
-
return snakeModuleName + '_' + snakeServiceName;
|
|
15
|
-
};
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
const methodsAvailable = ['post', 'get', 'patch', 'put', 'delete'];
|
|
2
|
-
|
|
3
|
-
export default ({ body }) => {
|
|
4
|
-
const serviceName = body.serviceName;
|
|
5
|
-
|
|
6
|
-
const methodMatched = serviceName.match(/^[a-z]*/);
|
|
7
|
-
if (!methodMatched || !methodsAvailable.includes(methodMatched[0]))
|
|
8
|
-
throw new Error('UNKNOWN_METHOD_TYPE: ' + serviceName);
|
|
9
|
-
|
|
10
|
-
return methodMatched[0];
|
|
11
|
-
}
|
package/service/getType/in.js
DELETED
package/service/getType/out.js
DELETED
|
@@ -1,105 +0,0 @@
|
|
|
1
|
-
export default async ({ body, ROUTE_CODE, SERVICES }) => {
|
|
2
|
-
const moduleName = body.moduleName;
|
|
3
|
-
const serviceCode = body.serviceCode;
|
|
4
|
-
|
|
5
|
-
const { serviceName, serviceRoute } = await SERVICES.service
|
|
6
|
-
.getParsedCode.handler({ moduleName, serviceCode });
|
|
7
|
-
|
|
8
|
-
const service =
|
|
9
|
-
await SERVICES.api.getService.handler({ moduleName, serviceName });
|
|
10
|
-
|
|
11
|
-
const ADDITIONAL_KEYS = { MODELS: await SERVICES.api.getModels.handler() };
|
|
12
|
-
|
|
13
|
-
const handler = async (event, res) => {
|
|
14
|
-
const { body: inBody, claims } =
|
|
15
|
-
await SERVICES.service.getParsedEvent.handler({ event });
|
|
16
|
-
|
|
17
|
-
let parsedInBody = inBody;
|
|
18
|
-
|
|
19
|
-
try {
|
|
20
|
-
const validationIn = await SERVICES.validation
|
|
21
|
-
.getParsedAsync.handler({ ROUTE_CODE: ROUTE_CODE+'_IN',
|
|
22
|
-
VALIDATOR: service.in, input: inBody });
|
|
23
|
-
|
|
24
|
-
if (validationIn?.error) {
|
|
25
|
-
await SERVICES.api.postInfo.handler({
|
|
26
|
-
VALIDATION_ERROR: validationIn.error });
|
|
27
|
-
res.status(400).json(validationIn.error);
|
|
28
|
-
return;
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
if (validationIn) parsedInBody = validationIn.parsedBody;
|
|
32
|
-
} catch (SERVICE_ERROR) {
|
|
33
|
-
const serviceRouteCode =
|
|
34
|
-
await SERVICES.service.getRouteCode.handler({
|
|
35
|
-
moduleName, serviceName });
|
|
36
|
-
|
|
37
|
-
await SERVICES.api.postError.handler({
|
|
38
|
-
STAGE: 'VALIDATION_IN',
|
|
39
|
-
[serviceRouteCode]: SERVICE_ERROR });
|
|
40
|
-
|
|
41
|
-
res.status(500).json({
|
|
42
|
-
[serviceRouteCode]: SERVICE_ERROR.toString() });
|
|
43
|
-
return;
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
let outBody = undefined;
|
|
47
|
-
try {
|
|
48
|
-
outBody = await service
|
|
49
|
-
.rawHandler(parsedInBody, claims);
|
|
50
|
-
|
|
51
|
-
} catch (SERVICE_ERROR) {
|
|
52
|
-
if (!service.error) {
|
|
53
|
-
const serviceRouteCode =
|
|
54
|
-
await SERVICES.service.getRouteCode.handler({
|
|
55
|
-
moduleName, serviceName });
|
|
56
|
-
|
|
57
|
-
await SERVICES.api.postError.handler({
|
|
58
|
-
STAGE: 'HANDLER',
|
|
59
|
-
[serviceRouteCode]: SERVICE_ERROR });
|
|
60
|
-
|
|
61
|
-
res.status(500).json({
|
|
62
|
-
[serviceRouteCode]: SERVICE_ERROR.toString() });
|
|
63
|
-
return;
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
outBody = await service.error(parsedInBody, claims);
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
let parsedOutBody = outBody;
|
|
70
|
-
|
|
71
|
-
try {
|
|
72
|
-
const validationOut = await SERVICES.validation
|
|
73
|
-
.getParsedAsync.handler({ ROUTE_CODE: ROUTE_CODE+'_OUT',
|
|
74
|
-
VALIDATOR: service.out, input: outBody });
|
|
75
|
-
|
|
76
|
-
if (validationOut?.error) {
|
|
77
|
-
await SERVICES.api.postInfo.handler({
|
|
78
|
-
VALIDATION_ERROR: validationOut.error });
|
|
79
|
-
res.status(400).json(validationOut.error);
|
|
80
|
-
return;
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
if (validationOut) parsedOutBody = validationOut.parsedBody;
|
|
84
|
-
} catch (SERVICE_ERROR) {
|
|
85
|
-
const serviceRouteCode =
|
|
86
|
-
await SERVICES.service.getRouteCode.handler({
|
|
87
|
-
moduleName, serviceName });
|
|
88
|
-
|
|
89
|
-
await SERVICES.api.postError.handler({
|
|
90
|
-
STAGE: 'VALIDATION_OUT',
|
|
91
|
-
[serviceRouteCode]: SERVICE_ERROR });
|
|
92
|
-
|
|
93
|
-
res.status(500).json({
|
|
94
|
-
[serviceRouteCode]: SERVICE_ERROR.toString() });
|
|
95
|
-
return;
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
const serviceResponseCode =
|
|
99
|
-
await SERVICES.service.getResponseCode.handler(service.type);
|
|
100
|
-
return res.status(serviceResponseCode).json(parsedOutBody);
|
|
101
|
-
};
|
|
102
|
-
|
|
103
|
-
await SERVICES.api.postRoute.handler({
|
|
104
|
-
method: service.type, route: serviceRoute, handler });
|
|
105
|
-
};
|
package/service/postRoute/in.js
DELETED
package/service/services.js
DELETED
package/setupTesting.js
DELETED
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import path from 'path';
|
|
2
|
-
import { getNewLib, z } from '@minimonolith/lib';
|
|
3
|
-
|
|
4
|
-
import modules from './modules.js';
|
|
5
|
-
|
|
6
|
-
const LIB = await getNewLib({ LOG_LEVEL: 1 });
|
|
7
|
-
|
|
8
|
-
await Promise.all(modules.map(module => LIB.postModule(module)));
|
|
9
|
-
|
|
10
|
-
const { SERVICES, COMPONENTS } = LIB;
|
|
11
|
-
const zdb = COMPONENTS.zdb;
|
|
12
|
-
const database = SERVICES.database;
|
|
13
|
-
const getServerFactory = SERVICES.server.getServerFactory.handler;
|
|
14
|
-
const autotest = SERVICES.autotest;
|
|
15
|
-
const getNewAPI = SERVICES.api.getNewAPI.handler;
|
|
16
|
-
|
|
17
|
-
export { z, zdb, database, getServerFactory, autotest, getNewAPI };
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
import { VALIDATION_MODULE } from '@minimonolith/lib';
|
|
2
|
-
|
|
3
|
-
export default async ({ body, SERVICES }) => {
|
|
4
|
-
const ROUTE_CODE = body.ROUTE_CODE;
|
|
5
|
-
const VALIDATOR = body.VALIDATOR;
|
|
6
|
-
const input = body.input;
|
|
7
|
-
const ADDITIONAL_KEYS = body.ADDITIONAL_KEYS;
|
|
8
|
-
|
|
9
|
-
const apiServices = await SERVICES.api.getServices.handler();
|
|
10
|
-
|
|
11
|
-
//const EVENT_CONTEXT = { SERVICES: apiServices, body: input };
|
|
12
|
-
const EVENT_CONTEXT = input;
|
|
13
|
-
|
|
14
|
-
if (!VALIDATOR && input) {
|
|
15
|
-
const MESSAGE = { ROUTE_CODE, VALIDATION_ERROR: 'BODY_NOT_ALLOWED' };
|
|
16
|
-
await SERVICES.api.postInfo.handler(MESSAGE);
|
|
17
|
-
return { error: MESSAGE };
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
if (!VALIDATOR) return undefined;
|
|
21
|
-
|
|
22
|
-
const zodobject = await VALIDATION_MODULE.getZodObject(ROUTE_CODE,
|
|
23
|
-
VALIDATOR(EVENT_CONTEXT));
|
|
24
|
-
|
|
25
|
-
const VALIDATION_RESULT = await VALIDATION_MODULE.getZodObject(ROUTE_CODE,
|
|
26
|
-
VALIDATOR(EVENT_CONTEXT)).safeParseAsync(input);
|
|
27
|
-
const VALIDATION_ERROR = VALIDATION_RESULT.error?.format();
|
|
28
|
-
|
|
29
|
-
if (VALIDATION_ERROR) {
|
|
30
|
-
const MESSAGE = { ROUTE_CODE,
|
|
31
|
-
VALIDATION_ERROR: JSON.stringify(VALIDATION_ERROR) };
|
|
32
|
-
//await SERVICES.api.postInfo.handler(MESSAGE);
|
|
33
|
-
return { error: MESSAGE };
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
return { parsedBody: VALIDATION_RESULT.data };
|
|
37
|
-
}
|
package/validation/services.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export default ['getParsedAsync'];
|
package/zdb/components.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export default ['getAssertExists', 'getAssertNotExists', 'getAssertSafeInt'];
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import { z } from '@minimonolith/lib';
|
|
2
|
-
|
|
3
|
-
export default ({ body }) => {
|
|
4
|
-
const model = body.model;
|
|
5
|
-
const field = body.field;
|
|
6
|
-
|
|
7
|
-
return async (value, ctx) => {
|
|
8
|
-
const valueCount = await model.count({ where: { [field]: value } });
|
|
9
|
-
if (valueCount == 0) {
|
|
10
|
-
ctx.addIssue({
|
|
11
|
-
code: z.ZodIssueCode.custom,
|
|
12
|
-
message: field.toUpperCase()+'_DOES_NOT_EXIST'
|
|
13
|
-
});
|
|
14
|
-
}
|
|
15
|
-
}
|
|
16
|
-
}
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import { z } from '@minimonolith/lib';
|
|
2
|
-
|
|
3
|
-
export default ({ body }) => {
|
|
4
|
-
const model = body.model;
|
|
5
|
-
const field = body.field;
|
|
6
|
-
|
|
7
|
-
return async (value, ctx) => {
|
|
8
|
-
const valueCount = await model.count({ where: { [field]: value } });
|
|
9
|
-
if (valueCount > 0) {
|
|
10
|
-
ctx.addIssue({
|
|
11
|
-
code: z.ZodIssueCode.custom,
|
|
12
|
-
message: field.toUpperCase()+'_ALREADY_EXISTS',
|
|
13
|
-
});
|
|
14
|
-
}
|
|
15
|
-
}
|
|
16
|
-
}
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import { z } from '@minimonolith/lib';
|
|
2
|
-
|
|
3
|
-
export default ({ body }) => {
|
|
4
|
-
const field = body.field;
|
|
5
|
-
|
|
6
|
-
return (rawValue, ctx) => {
|
|
7
|
-
const parsedValue = parseInt(rawValue, 10);
|
|
8
|
-
if (isNaN(parsedValue) || parsedValue.toString() !== rawValue) {
|
|
9
|
-
ctx.addIssue({
|
|
10
|
-
code: z.ZodIssueCode.custom,
|
|
11
|
-
message: field.toUpperCase()+'_NOT_A_SAFE_INT',
|
|
12
|
-
});
|
|
13
|
-
}
|
|
14
|
-
}
|
|
15
|
-
}
|
|
File without changes
|
|
File without changes
|
|
File without changes
|