Action as controller

Your Actions can be ran as Controllers that can be then registered as route handlers.

Implementing AsController

app/actions/users/delete_user_action.ts
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:

start/routes.ts
import  from '@adonisjs/core/services/router'
import  from '@foadonis/actions/services/main'
 
const  = () => import('#actions/users/delete_user_action')
 
.('/:userId', .())

On this page