herbsjs / herbs2rest

Create a REST API based on HerbsJS
MIT License
2 stars 13 forks source link

Problems in requesting variables of type boolean. #36

Closed daniel-goldacker closed 2 years ago

daniel-goldacker commented 2 years ago

Describe the bug Problems in requesting variables of type boolean .

To Reproduce

  1. Created a domain called "expense" and inside it I created two variables of type boolean . Images below: image image

  2. Created the "createExpense" use case to POST the information. I specified which parameters are accepted by the request. Images below: image image

  3. When running the application and making the postman call, the boolean variables of the request are not being read. Images to: image image

  4. Error getting in postman call because installment and paid fields are not coming .Images below: image

Expected behavior be able to access the value of variables of type boolean.

package.json dependencies "dependencies": { "@herbsjs/herbarium": "^1.4.0", "@herbsjs/herbs": "^1.5.0", "@herbsjs/herbs2knex": "^1.5.2", "@herbsjs/herbs2rest": "^2.0.2", "@herbsjs/herbsshelf": "^3.0.0", "cors": "^2.8.5", "deepmerge": "^4.2.2", "dotenv": "^16.0.1", "express": "^4.18.1", "generate-password": "^1.7.0", "lodash.camelcase": "^4.3.0", "mocha": "^10.0.0", "nodemon": "^2.0.15", "pg": "^8.7.3", "sugar-env": "^1.5.14" }

dalssoft commented 2 years ago

Hi @daniel-goldacker thank you for your bug report. The bug has been confirm and has already been fixed. Please update your herbs2rest version to 3.0.2 and try it again. Let us know if the bug persists.

daniel-goldacker commented 2 years ago

I updated the herbs2rest for version to 3.0.2 and tried to run it again. Now I'm having problem running the application.

Category endpoints /save-money/node_modules/@herbsjs/herbs2rest/src/generateRoutes.js:12 const entitySchemas = route.entity.prototype.meta.schema ^

TypeError: Cannot read properties of undefined (reading 'prototype') at /save-money/node_modules/@herbsjs/herbs2rest/src/generateRoutes.js:12:40 at Array.forEach () at generateRoutes (/save-money/node_modules/@herbsjs/herbs2rest/src/generateRoutes.js:9:10) at server (/save-money/src/infra/api/rest/index.js:58:5) at rest (/save-money/src/infra/api/rest/index.js:70:5) at Object.start (/save-money/src/infra/api/server.js:28:9) at Object. (/save-money/src/index.js:4:8) at Module._compile (node:internal/modules/cjs/loader:1105:14) at Object.Module._extensions..js (node:internal/modules/cjs/loader:1159:10) at Module.load (node:internal/modules/cjs/loader:981:32)

Would I need to update anything else?

Package.json dependencies: "dependencies": { "@herbsjs/herbarium": "^1.4.0", "@herbsjs/herbs": "^1.5.0", "@herbsjs/herbs2knex": "^1.5.2", "@herbsjs/herbs2rest": "^3.0.2", "@herbsjs/herbsshelf": "^3.0.0", "cors": "^2.8.5", "deepmerge": "^4.2.2", "dotenv": "^16.0.1", "express": "^4.18.1", "generate-password": "^1.7.0", "lodash.camelcase": "^4.3.0", "mocha": "^10.0.0", "nodemon": "^2.0.15", "pg": "^8.7.3", "sugar-env": "^1.5.14" }

dalssoft commented 2 years ago

All these core libs are under heavy development recently with some breaking changes.

I would recommend update your herbs-cli and create a new project, move your entities and use case to this new structure and test it there. Let us know if this solves the problem.

daniel-goldacker commented 2 years ago

I updated the version of herbjs to version 2.11.0 and migrated my /src folder to the new project created but I'm still having the error:

Category endpoints /teste/node_modules/@herbsjs/herbs2rest/src/generateRoutes.js:12 const entitySchemas = route.entity.prototype.meta.schema ^

TypeError: Cannot read properties of undefined (reading 'prototype') at /teste/node_modules/@herbsjs/herbs2rest/src/generateRoutes.js:12:40 at Array.forEach () at generateRoutes (/teste/node_modules/@herbsjs/herbs2rest/src/generateRoutes.js:9:10) at server (/teste/src/infra/api/rest/index.js:58:5) at rest (/teste/src/infra/api/rest/index.js:70:5) at Object.start (/teste/src/infra/api/server.js:28:9) at Object. (/teste/src/index.js:4:8) at Module._compile (node:internal/modules/cjs/loader:1105:14) at Object.Module._extensions..js (node:internal/modules/cjs/loader:1159:10) at Module.load (node:internal/modules/cjs/loader:981:32)

Package.json dependencies: "dependencies": { "@herbsjs/herbarium": "^1.4.0", "@herbsjs/herbs": "^1.6.1", "@herbsjs/herbs2knex": "^1.5.2", "@herbsjs/herbs2rest": "^3.0.1", "@herbsjs/herbsshelf": "^3.2.0", "cors": "^2.8.5", "deepmerge": "^4.2.2", "dotenv": "^16.0.1", "express": "^4.18.1", "generate-password": "^1.7.0", "lodash.camelcase": "^4.3.0", "mocha": "^10.0.0", "nodemon": "^2.0.15", "pg": "^8.7.3", "sugar-env": "^1.5.14" }

I made a test changing herbs2rest from version 3.0.1 to 3.0.2 and the problem also continued

dalssoft commented 2 years ago

@daniel-goldacker are you on Discord: https://discord.gg/AZh2jhzE There we can have a look at this specific error.

daniel-goldacker commented 2 years ago

I managed to resolve the error: "TypeError: Cannot read properties of undefined (reading 'prototype')"

Follow the step by step: 1 - I Updated the version of herbs-cli -> npm i -g @herbsjs/herbs-cli 2 - I Deleted node_modules folder from my project 3 - I Deleted file package-lock.json 4 - I Adjusted the file package.json with the new versions of herbs 5 - Redownloaded the project dependency packages -> npm install 6 - Went to the folder "src/infra/api/rest" in my project and in the file "index.js" changed the line "const controllers = { name: entity.group }" for "const controllers = { name: entity.group, entity: entity.id }"

Apparently there was a compatibility break in the implementation of const controllers parameters for those who were already using previous versions and migrated to a more recent one.