Skip to content

Commit

Permalink
chore: providing more info and context within the README
Browse files Browse the repository at this point in the history
  • Loading branch information
tomgobich committed Jun 1, 2024
1 parent 4f7ad28 commit 328c1f4
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 8 deletions.
33 changes: 26 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

Easily strub new action classes inside your AdonisJS 6 project

## Install With Ace
## Install with the Ace CLI
```shell
node ace add @adocasts.com/actions
```
Expand All @@ -19,21 +19,25 @@ Then, configure
node ace configure @adocasts.com/actions
```

## Using
## The Make Action Command
Once `@adocasts.com/actions` is installed & configured in your application,
you'll have access to `node ace make:actions [name]`.
you'll have access to the `node ace make:action [name]` command.

For example, to create a `RegisterFromForm` action, you can do:
```shell
node ace make:action RegisterFromForm
```
Which creates an action class at:
```shell
app/actions/register_from_form.ts
Which creates an action class at: `app/actions/register_from_form.ts`
```ts
export default class RegisterFromForm {
async handle() {
// do stuff
}
}
```

### Features
Apps have lots of actions, so it's a great idea to group them into feature/resource folders.
Apps have lots of actions they perform, so it's a great idea to group them into feature/resource folders.
This can be easily done via the `--feature` flag.
```shell
node ace make:action register_from_form --feature=auth
Expand All @@ -49,4 +53,19 @@ If your action is going to handle an HTTP Request, you can optionally include an
```shell
node ace make:action register_from_form --http --feature=auth
```
Which then creates: `app/actions/auth/register_from_form.ts`
```ts
import { inject } from '@adonisjs/core'
import type { HttpContext } from '@adonisjs/core/http'

@inject()
export default class RegisterFromForm {
constructor(protected ctx: HttpContext) {}

async handle() {
// do stuff
}
}
```
Unfamiliar with this approach? You can learn more via the [AdonisJS HTTP Context documentation](https://docs.adonisjs.com/guides/concepts/http-context#injecting-http-context-using-dependency-injection).

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@adocasts.com/actions",
"description": "Adds a make:action Ace CLI command to easily create new action handler classes in your AdonisJS 6 application",
"version": "0.0.2",
"version": "1.0.0",
"engines": {
"node": ">=20.6.0"
},
Expand Down

0 comments on commit 328c1f4

Please sign in to comment.