Skip to content

NekoNya-Backend v2.1.5

Latest
Compare
Choose a tag to compare
@TheDogHusky TheDogHusky released this 02 Oct 15:45
· 3 commits to main since this release

This release includes a major bug fix that changes a bit how the API works.

Changes

  • 03914d9 Added express-async-errors to catch asynchronous errors from express
  • 03914d9 Added on-finished and on-headers as dependencies of the logger
  • 03914d9 Changed the way errors are sent from the API to a definitive and clean one:
    Instead of a reponse with error, message and status like I wrote in the docs, which was almost always false, the errors are now in a definitive format:
{
    "error": {
        "message": "The message of the error",
        "code": 500,
        "type": "the type of the error (mostly useful in the backend)"
    }
}

And if the route contained validation:

{
    "error": {
        "message": "Validation Failed",
        "code": 400,
        "type": "ValidationError"
    },
    "errors": {
        ...
    }
}

Where the errors field contains express-validator's validationResults#array.

  • 03914d9 Changed the way the endpoints were being grabbed: this is now automated from a property infos of type APIRouteInfos that is retrieved at the start of the backend
  • 03914d9 Optimized the owoify route with an unified middleware to handle the requests in both POST and GET methods

Fixes

  • 03914d9 Fixed incorrect times and status codes from the logger
  • 03914d9 Fixed the lack of error handling which caused the backend to crash
  • 03914d9 Fixed dependency loop in the API loading (files index) because of a wrong condition