minimonolith 0.25.6 → 0.25.9

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.
@@ -1,39 +1,32 @@
1
1
  import getLambdaAPI from 'lambda-api';
2
2
 
3
- import { getNewLib, /*LOG_SERVICE*/ } from '@minimonolith/lib';
3
+ import { getNewLib } from '@minimonolith/lib';
4
4
 
5
5
  import { setAPI } from '../api.js';
6
6
 
7
7
  import CORS_HEADERS from '../corsHeaders.js';
8
8
 
9
9
  export default async ({ body, SERVICES }) => {
10
- const DEV_ENV = body.DEV_ENV;
11
- const PROD_ENV = body.PROD_ENV;
12
- const TEST_ENV = body.TEST_ENV;
10
+ //const LOG_LEVEL = body.LOG_LEVEL;
11
+ const LOG_LEVEL = body;
13
12
 
14
13
  const API = {
15
14
  ROUTES: getLambdaAPI(),
16
- //LIB: await getNewLib({ DEBUG: 'TRUE' }),
17
- LIB: await getNewLib(),
15
+ LIB: await getNewLib({ LOG_LEVEL }),
18
16
  SCHEMAS: {},
19
17
  MODELS: {},
20
18
  ORM: undefined,
21
- DEV_ENV: DEV_ENV,
22
- PROD_ENV: PROD_ENV,
23
- TEST_ENV: TEST_ENV,
24
19
  };
25
20
 
26
21
  API.ROUTES.use((req, res, next) => {
27
22
  if (req.headers['x-trigger-error']) {
28
- /*
29
- LOG_SERVICE.post({
23
+ const MESSAGE ={
30
24
  ROUTE_CODE: 'LAMBDA_API',
31
25
  MESSAGE: 'X_TRIGGER_ERROR_HEADER'
32
- });
33
- */
34
- throw new Error('X_TRIGGER_ERROR_HEADER');
26
+ }
27
+ API.LIB.error(MESSAGE);
28
+ throw new Error(JSON.stringify(MESSAGE));
35
29
  }
36
- //console.log('passes here');
37
30
  res.cors(); next();
38
31
  });
39
32
 
@@ -1,7 +1,8 @@
1
1
  import { z } from '@minimonolith/lib';
2
2
 
3
+ export default () => z.number().default(2);
4
+ /*
3
5
  export default () => ({
4
- DEV_ENV: z.string().default('FALSE'),
5
- PROD_ENV: z.string().default('TRUE'),
6
- TEST_ENV: z.string().default('FALSE'),
6
+ LOG_LEVEL: z.number().default(2),
7
7
  });
8
+ */
@@ -1,13 +1,11 @@
1
1
  import getLambdaAPI from 'lambda-api';
2
- //import { LOG_SERVICE } from '@minimonolith/lib';
3
2
 
4
3
  import API from '../api.js';
5
4
 
6
5
  export default async ({ body, ROUTE_CODE, SERVICES }) => {
7
6
 
8
7
  API().ROUTES.use((err, req, res, next) => {
9
- //LOG_SERVICE.postError({ ROUTE_CODE: 'LAMBDA_API', ERROR: err });
10
- console.log({ ROUTE_CODE: 'LAMBDA_API', ERROR: err });
8
+ API().LIB.error({ ROUTE_CODE: 'LAMBDA_API', ERROR: err });
11
9
  res.cors(); //next();
12
10
  res.status(500).send({ ROUTE_CODE: 'LAMBDA_API', ERROR: err.message });
13
11
  });
@@ -16,25 +14,15 @@ export default async ({ body, ROUTE_CODE, SERVICES }) => {
16
14
 
17
15
  API().LIB.postAdditionalKey('MODELS', API().MODELS);
18
16
 
19
- //LOG_SERVICE.post({ ROUTE_CODE, INFO: 'LISTENING' });
20
- console.log({ ROUTE_CODE, INFO: 'LISTENING' });
17
+ API().LIB.info({ ROUTE_CODE, INFO: 'LISTENING' });
21
18
 
22
19
  return async (event, context) => {
23
- /*
24
- LOG_SERVICE.post({
25
- ROUTE_CODE: 'LAMBDA_EVENT',
26
- PATH: event.requestContext?.http?.path,
27
- METHOD: event.requestContext?.http?.method,
28
- });
29
- */
30
- console.log({
20
+ API().LIB.info({
31
21
  ROUTE_CODE: 'LAMBDA_EVENT',
32
22
  PATH: event.requestContext?.http?.path,
33
23
  METHOD: event.requestContext?.http?.method,
34
24
  });
35
25
 
36
- //API().ROUTES.routes(true);
37
- //return await api.run({ event, context });
38
26
  return await API().ROUTES.run(event, context);
39
27
  };
40
28
  };
@@ -0,0 +1,5 @@
1
+ import API from '../api.js';
2
+
3
+ export default ({ body }) => {
4
+ API().LIB.debug(body);
5
+ }
@@ -0,0 +1,3 @@
1
+ import { z } from '@minimonolith/lib';
2
+
3
+ export default () => z.unknown();
@@ -0,0 +1,5 @@
1
+ import API from '../api.js';
2
+
3
+ export default ({ body }) => {
4
+ API().LIB.error(body);
5
+ }
@@ -0,0 +1,3 @@
1
+ import { z } from '@minimonolith/lib';
2
+
3
+ export default () => z.unknown();
@@ -0,0 +1,5 @@
1
+ import API from '../api.js';
2
+
3
+ export default ({ body }) => {
4
+ API()?.LIB.info(body);
5
+ }
@@ -0,0 +1,3 @@
1
+ import { z } from '@minimonolith/lib';
2
+
3
+ export default () => z.unknown();
package/api/services.js CHANGED
@@ -12,4 +12,7 @@ export default [
12
12
  'postSchema',
13
13
  'postORM',
14
14
  'postModel',
15
+ 'postInfo',
16
+ 'postDebug',
17
+ 'postError',
15
18
  ];
@@ -1,8 +1,6 @@
1
1
  import Sequelize from 'sequelize';
2
2
  //import SequelizeDynamo from 'dynamo-sequelize';
3
3
 
4
- //import { LOG_SERVICE } from '@minimonolith/lib';
5
-
6
4
  export default async ({ body, SERVICES, ROUTE }) => {
7
5
  const dialect = body.dialect;
8
6
  const host = body.host;
@@ -13,10 +11,12 @@ export default async ({ body, SERVICES, ROUTE }) => {
13
11
  const storage = body.storage;
14
12
 
15
13
  const SEQUELIZE_OPTIONS = { dialect, host, port, storage, logging: false };
16
- console.log('SEQUELIZE_OPTIONS', SEQUELIZE_OPTIONS);
17
14
 
18
- //LOG_SERVICE.postQA({ ROUTE, DB_VARS: {
19
- // dialect, host, port, db, user, pass, storage }});
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
20
 
21
21
  const ORM = new Sequelize(db, user, pass, SEQUELIZE_OPTIONS);
22
22
  await SERVICES.api.postORM.handler({ ORM });
@@ -1,6 +1,4 @@
1
- //import { LOG_SERVICE } from '@minimonolith/lib';
2
-
3
- export default async ({ body, ROUTE_CODE }) => {
1
+ export default async ({ body, ROUTE_CODE, SERVICES }) => {
4
2
  const ORM = body.ORM;
5
3
 
6
4
  const MAX_RETRIES = 5, INITIAL_WAIT = 100;
@@ -8,8 +6,8 @@ export default async ({ body, ROUTE_CODE }) => {
8
6
 
9
7
  while (connectionRetries < MAX_RETRIES) {
10
8
  try {
11
- //LOG_SERVICE.post({ ROUTE_CODE, AUTH_INTENT: connectionRetries });
12
- console.log({ ROUTE_CODE, AUTH_INTENT: connectionRetries });
9
+ await SERVICES.api.postInfo.handler({
10
+ ROUTE_CODE, AUTH_INTENT: connectionRetries });
13
11
  await ORM.authenticate();
14
12
  break;
15
13
 
@@ -2,7 +2,7 @@ import path from 'path';
2
2
  import url from 'url';
3
3
  import dotenv from 'dotenv';
4
4
 
5
- import { /*LOG_SERVICE,*/ PATH_MODULE } from '@minimonolith/lib';
5
+ import { PATH_MODULE } from '@minimonolith/lib';
6
6
 
7
7
  export default async ({ body }) => {
8
8
  const envFile = body.envFile;
@@ -10,11 +10,7 @@ export default async ({ body }) => {
10
10
 
11
11
  const projectRootFileUrl = PATH_MODULE.getProjectRoot(
12
12
  import.meta.url, modulesFolder);
13
- console.log('meta url', import.meta.url);
14
- console.log('modulesFolder', modulesFolder);
15
13
  const projectRootPath = url.fileURLToPath(projectRootFileUrl + path.sep);
16
- console.log('projectRootPath', projectRootPath);
17
14
  const envFilePath = path.resolve(projectRootPath, envFile)
18
- console.log('envFilePath', envFilePath);
19
15
  dotenv.config({ path: envFilePath });
20
16
  };
@@ -1,12 +1,9 @@
1
- //import { LOG_SERVICE } from '@minimonolith/lib';
2
-
3
1
  export default async ({ SERVICES }) => {
4
2
  const method = 'get';
5
3
  const route = '/';
6
4
  const handler = async (req, res) => {
7
5
  const SERVICE_RESPONSE = "API_RUNNING";
8
- //LOG_SERVICE.post({ SERVICE_RESPONSE });
9
- console.log({ SERVICE_RESPONSE });
6
+ await SERVICES.api.postInfo.handler({ SERVICE_RESPONSE });
10
7
  return { SERVICE_RESPONSE: "API_RUNNING" };
11
8
  }
12
9
 
package/index.js CHANGED
@@ -3,8 +3,7 @@ import { getNewLib, z } from '@minimonolith/lib';
3
3
 
4
4
  import modules from './modules.js';
5
5
 
6
- //const LIB = await getNewLib({ DEBUG: 'TRUE' });
7
- const LIB = await getNewLib();
6
+ const LIB = await getNewLib({ LOG_LEVEL: 1 );
8
7
 
9
8
  await Promise.all(modules.map(module => LIB.postModule(
10
9
  module,
@@ -1,14 +1,12 @@
1
1
  import { DataTypes } from 'sequelize';
2
2
 
3
- //import { LOG_SERVICE } from '@minimonolith/lib';
4
-
5
3
  export default async ({ ROUTE_CODE, SERVICES }) => {
6
4
  const SCHEMAS = await SERVICES.api.getSchemas.handler();
7
5
  const ORM = await SERVICES.api.getORM.handler();
8
6
 
9
- //for (const moduleName of SCHEMAS) {
10
7
  for (const moduleName of Object.keys(SCHEMAS)) {
11
- //LOG_SERVICE.post({ ROUTE_CODE, LOADING: moduleName });
8
+ await SERVICES.api.postInfo.handler({
9
+ ROUTE_CODE, LOADING: moduleName });
12
10
 
13
11
  const model = SCHEMAS[moduleName](ORM, DataTypes);
14
12
  await SERVICES.api.postModel.handler({ moduleName, model });
@@ -17,12 +15,15 @@ export default async ({ ROUTE_CODE, SERVICES }) => {
17
15
  const MODELS = await SERVICES.api.getModels.handler();
18
16
 
19
17
  for (const [moduleName, MODEL] of Object.entries(MODELS)) {
20
- //LOG_SERVICE.post({ ROUTE_CODE, ASSOCIATING: moduleName });
18
+ await SERVICES.api.postInfo.handler({
19
+ ROUTE_CODE, ASSOCIATING: moduleName });
21
20
  MODEL.associate(MODELS);
22
21
  }
23
22
 
24
- //LOG_SERVICE.post({ ROUTE_CODE, SYNCING_ORM: 'WAITING_ORM_SYNCING' });
23
+ await SERVICES.api.postInfo.handler({
24
+ ROUTE_CODE, SYNCING_ORM: 'WAITING_ORM_SYNCING' });
25
25
  await ORM.sync({ alter: process.env.DEV_ENV==='TRUE' ? true : false });
26
26
 
27
- //LOG_SERVICE.post({ ROUTE_CODE, SYNCING_ORM: 'DONE_ORM_SYNCING' });
27
+ await SERVICES.api.postInfo.handler({
28
+ ROUTE_CODE, SYNCING_ORM: 'DONE_ORM_SYNCING' });
28
29
  };
@@ -1,15 +1,12 @@
1
1
  import fs from 'fs';
2
2
  import url from 'url';
3
3
 
4
- //import { LOG_SERVICE } from '@minimonolith/lib';
5
-
6
4
  export default async ({ body, SERVICES }) => {
7
5
  const moduleName = body.moduleName;
8
6
  const moduleURL = body.moduleURL;
9
7
 
10
- //console.log('moduleURL', moduleURL);
11
8
  if (!fs.existsSync(url.fileURLToPath(`${moduleURL}model.js`))) return;
12
- //LOG_SERVICE.post({ messages: [' FOUND_MODEL'] })
9
+ await SERVICES.api.postInfo.handler(` FOUND_MODEL ${moduleName}`)
13
10
 
14
11
  const moduleSchema =
15
12
  (await import(`${moduleURL}model.js`)).default(moduleName);
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "minimonolith",
3
3
  "type": "module",
4
- "version": "0.25.6",
4
+ "version": "0.25.9",
5
5
  "main": "index.js",
6
6
  "license": "MIT",
7
7
  "scripts": {
@@ -14,7 +14,7 @@
14
14
  "sequelize"
15
15
  ],
16
16
  "dependencies": {
17
- "@minimonolith/lib": "^0.13.1",
17
+ "@minimonolith/lib": "^0.14.2",
18
18
  "lambda-api": "^1.0.3",
19
19
  "sequelize": "^6.30.0",
20
20
  "zod": "^3.21.4"
@@ -2,8 +2,6 @@
2
2
 
3
3
  import url from 'url';
4
4
 
5
- //import { LOG_SERVICE } from '@minimonolith/lib';
6
-
7
5
  import CORS_HEADERS from '../../api/corsHeaders.js';
8
6
 
9
7
  const getBody = req => {
@@ -62,7 +60,7 @@ export default lambdaHandler => async (req, res) => {
62
60
 
63
61
  } catch(SERVER_ERROR) {
64
62
  //LOG_SERVICE.post({ SERVER_ERROR });
65
- console.log({ SERVER_ERROR });
63
+ console.error({ SERVER_ERROR });
66
64
  res.statusCode = 500;
67
65
  for (let k in CORS_HEADERS) res.setHeader(k, CORS_HEADERS[k]);
68
66
  res.end(JSON.stringify({ REQUEST_PARSING_ERROR: SERVER_ERROR.toString() }));
@@ -15,11 +15,5 @@ export default ({ body }) => {
15
15
  `/${relativeServiceRoute.substring(1)}/${moduleName}` :
16
16
  `/${moduleName}/${relativeServiceRoute}`;
17
17
 
18
- /*
19
- console.log('serviceRoute', '['+relativeServiceRoute+']');
20
- console.log('serviceRoute',
21
- relativeServiceRoute.substring(1), 'fdfd', serviceRoute);
22
- */
23
-
24
18
  return { serviceName, serviceRoute };
25
19
  };
@@ -1,6 +1,3 @@
1
- //import LOG_SERVICE from '../../log/index.js';
2
- //import { LOG_SERVICE } from '@minimonolith/lib';
3
-
4
1
  export default async ({ body, ROUTE_CODE, SERVICES }) => {
5
2
  const moduleName = body.moduleName;
6
3
  const serviceCode = body.serviceCode;
@@ -11,32 +8,28 @@ export default async ({ body, ROUTE_CODE, SERVICES }) => {
11
8
  const service =
12
9
  await SERVICES.api.getService.handler({ moduleName, serviceName });
13
10
 
14
- //const method = await SERVICES.service.getType.handler({ serviceName });
15
11
  const ADDITIONAL_KEYS = { MODELS: await SERVICES.api.getModels.handler() };
16
12
 
17
13
  const handler = async (event, res) => {
18
14
  const { body: inBody, claims } =
19
15
  await SERVICES.service.getParsedEvent.handler({ event });
20
- //const service =
21
- // await SERVICES.api.getService.handler({ moduleName, serviceName });
22
16
 
23
17
  let parsedInBody = inBody;
24
- //console.log('service', service);
25
18
 
26
- //if (service.in) {
19
+ {
27
20
  const validationIn = await SERVICES.validation
28
21
  .getParsedAsync.handler({ ROUTE_CODE: ROUTE_CODE+'_IN',
29
22
  VALIDATOR: service.in, input: inBody });
30
23
 
31
24
  if (validationIn?.error) {
32
- //LOG_SERVICE.post({ VALIDATION_ERROR: validationIn.error });
33
- console.log({ VALIDATION_ERROR: validationIn.error });
25
+ await SERVICES.api.postInfo.handler({
26
+ VALIDATION_ERROR: validationIn.error });
34
27
  res.status(400).json(validationIn.error);
35
28
  return;
36
29
  }
37
30
 
38
31
  if (validationIn) parsedInBody = validationIn.parsedBody;
39
- //}
32
+ }
40
33
 
41
34
  let outBody = undefined;
42
35
  try {
@@ -45,8 +38,7 @@ export default async ({ body, ROUTE_CODE, SERVICES }) => {
45
38
 
46
39
  } catch (SERVICE_ERROR) {
47
40
  if (!service.error) {
48
- //LOG_SERVICE.post({ SERVICE_ERROR });
49
- console.log({ SERVICE_ERROR });
41
+ await SERVICES.api.postError.handler({ SERVICE_ERROR });
50
42
  res.status(500).json(SERVICE_ERROR);
51
43
  return;
52
44
  }
@@ -55,24 +47,23 @@ export default async ({ body, ROUTE_CODE, SERVICES }) => {
55
47
  }
56
48
 
57
49
  let parsedOutBody = outBody;
58
- //if (service.out) {
50
+
51
+ {
59
52
  const validationOut = await SERVICES.validation
60
53
  .getParsedAsync.handler({ ROUTE_CODE: ROUTE_CODE+'_OUT',
61
54
  VALIDATOR: service.out, input: outBody });
62
55
 
63
56
  if (validationOut?.error) {
64
- //LOG_SERVICE.post({ VALIDATION_ERROR: validationOut.error });
65
- console.log({ VALIDATION_ERROR: validationOut.error });
57
+ await SERVICES.api.postInfo.handler({
58
+ VALIDATION_ERROR: validationOut.error });
66
59
  res.status(400).json(validationOut.error);
67
60
  return;
68
61
  }
69
62
 
70
63
  if (validationOut) parsedOutBody = validationOut.parsedBody;
71
- //}
64
+ }
72
65
 
73
- //console.log('method', method);
74
66
  const serviceResponseCode =
75
- //await SERVICES.service.getResponseCode.handler(method);
76
67
  await SERVICES.service.getResponseCode.handler(service.type);
77
68
  return res.status(serviceResponseCode).json(parsedOutBody);
78
69
  };
package/setupTesting.js CHANGED
@@ -3,12 +3,10 @@ import { getNewLib, z } from '@minimonolith/lib';
3
3
 
4
4
  import modules from './modules.js';
5
5
 
6
- //const LIB = await getNewLib({ DEBUG: 'TRUE' });
7
- const LIB = await getNewLib();
6
+ const LIB = await getNewLib({ LOG_LEVEL: 1 });
8
7
 
9
8
  await Promise.all(modules.map(module => LIB.postModule(module)));
10
9
 
11
-
12
10
  const { SERVICES, COMPONENTS } = LIB;
13
11
  const zdb = COMPONENTS.zdb;
14
12
  const database = SERVICES.database;
@@ -1,40 +1,36 @@
1
- import { /*LOG_SERVICE,*/ VALIDATION_MODULE } from '@minimonolith/lib';
1
+ import { VALIDATION_MODULE } from '@minimonolith/lib';
2
2
 
3
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 EVENT_CONTEXT = { SERVICES, body: input };
10
- //console.log('EVENT_CONTEXT', EVENT_CONTEXT);
11
- console.log('EVENT_CONTEXT\n', '----------------------\n',
12
- EVENT_CONTEXT, '\n------------------------');
13
-
14
- if (!VALIDATOR && input) {
15
- const MESSAGE = { ROUTE_CODE,
16
- VALIDATION_ERROR: JSON.stringify({ message: 'BODY_NOT_ALLOWED' }) };
17
- //LOG_MODULE.postError(MESSAGE);
18
- console.error(MESSAGE);
19
- return { error: MESSAGE };
20
- }
21
-
22
- if (!VALIDATOR) return undefined;
23
-
24
- const zodobject = await VALIDATION_MODULE.getZodObject(ROUTE_CODE,
25
- VALIDATOR(EVENT_CONTEXT));
26
-
27
- const VALIDATION_RESULT = await VALIDATION_MODULE.getZodObject(ROUTE_CODE,
28
- VALIDATOR(EVENT_CONTEXT)).safeParseAsync(input);
29
- const VALIDATION_ERROR = VALIDATION_RESULT.error?.format();
30
-
31
- if (VALIDATION_ERROR) {
32
- const MESSAGE = { ROUTE_CODE,
33
- VALIDATION_ERROR: JSON.stringify(VALIDATION_ERROR) };
34
- //LOG_MODULE.postError(MESSAGE);
35
- console.error(MESSAGE);
36
- return { error: MESSAGE };
37
- }
38
-
39
- return { parsedBody: VALIDATION_RESULT.data };
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
+
13
+ if (!VALIDATOR && input) {
14
+ const MESSAGE = { ROUTE_CODE, VALIDATION_ERROR: 'BODY_NOT_ALLOWED' };
15
+ await SERVICES.api.postInfo.handler(MESSAGE);
16
+ return { error: MESSAGE };
17
+ }
18
+
19
+ if (!VALIDATOR) return undefined;
20
+
21
+ const zodobject = await VALIDATION_MODULE.getZodObject(ROUTE_CODE,
22
+ VALIDATOR(EVENT_CONTEXT));
23
+
24
+ const VALIDATION_RESULT = await VALIDATION_MODULE.getZodObject(ROUTE_CODE,
25
+ VALIDATOR(EVENT_CONTEXT)).safeParseAsync(input);
26
+ const VALIDATION_ERROR = VALIDATION_RESULT.error?.format();
27
+
28
+ if (VALIDATION_ERROR) {
29
+ const MESSAGE = { ROUTE_CODE,
30
+ VALIDATION_ERROR: JSON.stringify(VALIDATION_ERROR) };
31
+ await SERVICES.api.postInfo.handler(MESSAGE);
32
+ return { error: MESSAGE };
33
+ }
34
+
35
+ return { parsedBody: VALIDATION_RESULT.data };
40
36
  }
package/error/index.js DELETED
@@ -1,4 +0,0 @@
1
- import postCompiletime from './postCompiletime/index.js';
2
- import postRuntime from './postRuntime/index.js';
3
-
4
- export default { postCompiletime, postRuntime };
@@ -1,13 +0,0 @@
1
- import API_SERVICE from '../../api/index.js';
2
- import LOG_SERVICE from '../../log/index.js';
3
-
4
- export default ({ META_SERVICE_NAME, META_METHOD_NAME, ROUTE_CODE, META_METHOD_ERROR }) => {
5
- LOG_SERVICE.postError({
6
- META_SERVICE_NAME,
7
- META_METHOD_NAME,
8
- ROUTE_CODE,
9
- META_METHOD_ERROR,
10
- STACK_TRACE: META_METHOD_ERROR?.stack,
11
- });
12
- if (API_SERVICE.get().DEV_ENV==='TRUE') throw META_METHOD_ERROR;
13
- };
@@ -1,7 +0,0 @@
1
- import LOG_SERVICE from '../../log/index.js';
2
-
3
- export default (res, ROUTE_CODE, METHOD_ERROR) => {
4
- const MESSAGE = { ROUTE_CODE, METHOD_ERROR: METHOD_ERROR.stack.toString() };
5
- LOG_SERVICE.postError(MESSAGE);
6
- res.status(500).json(MESSAGE);
7
- }
package/log/index.js DELETED
@@ -1,5 +0,0 @@
1
- import post from './post/index.js';
2
- import postError from './postError/index.js';
3
- import postQA from './postQA/index.js';
4
-
5
- export default { post, postError, postQA };
package/log/post/index.js DELETED
@@ -1,3 +0,0 @@
1
- import API_SERVICE from '../../api/index.js';
2
-
3
- export default (...MESSAGE) => { console.log(...MESSAGE); };
@@ -1,3 +0,0 @@
1
- import API_SERVICE from '../../api/index.js';
2
-
3
- export default (...ERROR) => { console.error(...ERROR); };
@@ -1,3 +0,0 @@
1
- import API_SERVICE from '../../api/index.js';
2
-
3
- export default (...MESSAGE) => { if (API_SERVICE.get().PROD_ENV==='FALSE') { console.log(...MESSAGE); } };
@@ -1,13 +0,0 @@
1
- import API_SERVICE from '../../api/index.js';
2
- import LOG_SERVICE from '../../log/index.js';
3
-
4
- import getResponseCode from '../getResponseCode/index.js';
5
-
6
- export default async (res, ROUTE_CODE, CONTROLLER, METHOD_TYPE, body, claims) => {
7
-
8
- const { MODELS, SERVICES } = API_SERVICE.get();
9
- const METHOD_RESPONSE = await CONTROLLER({ MODELS, SERVICES, body, claims });
10
- const METHOD_RESPONSE_CODE = getResponseCode(METHOD_TYPE);
11
- LOG_SERVICE.post({ ROUTE_CODE, METHOD_RESPONSE });
12
- res.status(METHOD_RESPONSE_CODE).json(METHOD_RESPONSE);
13
- };