ambrosus / ambrosus-node-extended

Expanded reporting and organizational functionality for the Hermes node.
MIT License
5 stars 5 forks source link

Error validation authorize #27

Closed lazar-eric closed 5 years ago

conorseabrook commented 5 years ago

In the postman project 'Get Organization' fails validation. The param integer seems to be the issue.

GET http://localhost:3000/organization/27

Result

{
    "meta": {
        "message": "Invalid data: organizationId should be integer",
        "code": 400
    }
}

Same for 'Get Organization Accounts' and 'Modify Organization'

conorseabrook commented 5 years ago

@lazar-eric Attempting to create a new organization with an existing public key is crashing the server. This should be a known application error, but obviously we shouldn't crash the server with 'process.exit(1);' for unknown errors either. Anything unknown should be logged/sent to Sentry and the user should get a generic unknown exception message.

conorseabrook commented 5 years ago

Let's use kebab-case for files to keep it consistent (ie: express-errorhandler.middleware.ts).

What about just error-handler.middleware.ts?

conorseabrook commented 5 years ago

{{url}}/organization/request/0xc0ffee254729296a45a3885639AC7E10F9d54979

{
    "meta": {
        "message": "Invalid data: address should be string",
        "code": 400
    }
}
conorseabrook commented 5 years ago

This is what I'm seeing if I disable the unhandledRejection listener.

(node:5608) UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'params' of undefined
    at Object.<anonymous> (/Users/conor/projects/ambrosus-node-extended/src/middleware/validation.middleware.ts:29:17)
    at Generator.next (<anonymous>)
    at /Users/conor/projects/ambrosus-node-extended/src/middleware/validation.middleware.ts:7:71
    at new Promise (<anonymous>)
    at __awaiter (/Users/conor/projects/ambrosus-node-extended/src/middleware/validation.middleware.ts:3:12)
    at /Users/conor/projects/ambrosus-node-extended/src/middleware/validation.middleware.ts:9:68
conorseabrook commented 5 years ago

This isn't a user error, it's an error to notify the developer that they haven't implemented the subclass correctly.

{
    "meta": {
        "message": "Repository error: timestampField getter must be overridden!",
        "code": 400
    }
}
conorseabrook commented 5 years ago

Feel free to merge.