adonis-resource-controller
Restful resource controller for AdonisJs
Usage
- Requirements
Please install adonis-resource-middleware first, and setup the routes with
resource
middleware. After that, your/start/routes.js
should looks like this:
const Route = Route
- Installnpm i -S adonis-resource-controller
- Make a controller:
/app/Controllers/Http/ResourceController.js
const BaseController =moduleexports =
CRUD Routes.
Now, you can play CRUD with your APIs. AllREST-ADMIN
forThe routes and returned data gave a first-class supporting for
rest-admin
- A Powerful Admin Dashboard based onvue2
+bootstrap4
Usage
Let's getting start with CRUD for users.
-
Open your
/app/Models/User.js
, add afields()
method:static {return_id: label: 'ID'username: label: 'Username' cols: 3password: label: 'Password' type: 'password' listable: false cols: 3is_active: label: 'Is Active' type: 'switch' cols: 3 editable: falsemember_type: label: 'Member Type' type: 'select' options:text: 'VIP' value: 1text: 'GOLD' value: 2intro: label: 'Intro' type: 'html' cols: 6 listable: false} -
Clone rest-admin
-
Copy
.env
to.env.development.local
, open it, and change the API URL to the AdonisJs server api url:VUE_APP_API_URL=http://localhost:3333/api/ -
npm run dev
Is that what you want? :)