adonis-resource-middleware
Restful resource middleware for AdonisJs
Usage
-
Install
npm i -S adonis-resource-middleware -
Edit
/start/kernel.js
const namedMiddleware =/* ... *//* add a named middleware */resource: 'adonis-resource-middleware' -
In your
/start/routes.js
:Route/* Specify the resource name */Route/* The 2nd param specify if throw exceptions automatically */Route/* Also you can ignore the 1st param */RouteRoute/* also you can use `Route.resource` */Route
Handle Exceptions
It throws exceptions by default, also you can handle it, please check The Official Docs of Handling Exceptions.
-
E_RESOURCE_MODEL_CLASS_NOT_FOUND
If the model class does not exists inApp/Models/
. -
E_RESOURCE_MODEL_NOT_FOUND
If the record does not exists in the database.