Action as controller
Your Actions can be ran as Controllers that can be then registered as route handlers.
Implementing AsController
import from '#models/user'
import { , AsController } from '@foadonis/actions'
import { } from '@adonisjs/core/http'
export default class extends implements AsController {
async (: ) {
await .delete()
}
async ({ }: ) {
const = .('id')
const = await .findOrFail()
await this.()
return
}
}Registering the route
You can then use your Action as a route handler:
import from '@adonisjs/core/services/router'
import from '@foadonis/actions/services/main'
const = () => import('#actions/users/delete_user_action')
.('/:userId', .())