minimonolith 0.4.0 → 0.5.0

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/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "minimonolith",
3
3
  "type": "module",
4
- "version": "0.4.0",
4
+ "version": "0.5.0",
5
5
  "main": "index.js",
6
6
  "license": "MIT",
7
7
  "scripts": {
@@ -1,7 +1,8 @@
1
1
  const modelSchemas = {};
2
2
 
3
- export const registerModel = (serviceName, modelSchema) => {
4
- modelSchemas[serviceName] = modelSchema(serviceName);
3
+ export const registerModel = async (SERVICE_NAME, SERVICE_URL) => {
4
+ const SERVICE_MODEL_MODULE = await import(`${SERVICE_URL}model.js`);
5
+ modelSchemas[SERVICE_NAME] = SERVICE_MODEL_MODULE.modelSchema(SERVICE_NAME);
5
6
  }
6
7
 
7
8
  export const loadModels = (orm, types) => {
@@ -11,11 +11,11 @@ const serviceHandler = async (API, SERVICE_NAME, SRC_FOLDER, MODULE_FOLDER) => {
11
11
  try {
12
12
  const PROJECT_ROOT_PATH = getProjectRoot(import.meta.url, MODULE_FOLDER)+'/';
13
13
  const PROJECT_RELATIVE_SERVICE_PATH = './' + SRC_FOLDER + `${SERVICE_NAME}/`;
14
- //const SERVICE_URL = new URL(RELATIVE_SERVICE_PATH, url.pathToFileURL(process.cwd()+'/'));
15
14
  const SERVICE_URL = new URL(PROJECT_RELATIVE_SERVICE_PATH, PROJECT_ROOT_PATH);
16
15
  const SERVICE_MODULE = await import(`${SERVICE_URL}index.js`);
17
16
 
18
- if (SERVICE_MODULE.modelSchema) registerModel(SERVICE_NAME, SERVICE_MODULE.modelSchema);
17
+ //if (SERVICE_MODULE.modelSchema) registerModel(SERVICE_NAME, SERVICE_MODULE.modelSchema);
18
+ if (SERVICE_MODULE.model) registerModel(SERVICE_NAME, SERVICE_URL);
19
19
  const SERVICE_METHODS = await registerMethods(SERVICE_MODULE.methods)(SERVICE_URL);
20
20
 
21
21
  Object.keys(SERVICE_METHODS).forEach(METHOD_NAME => {
package/todoList/index.js CHANGED
@@ -1,5 +1,2 @@
1
- import { modelSchema } from './model.js';
2
-
3
- const methods = ['get', 'post', 'delete'];
4
-
5
- export { modelSchema, methods };
1
+ export const model = true;
2
+ export const methods = ['get', 'post', 'delete'];