Skip to content

lukfor85/adonisjs-girouette

Repository files navigation

Girouette

Girouette is a AdonisJS package providing decorators to handle routing.

npm-image license-image typescript-image

Installation

npm install @softwarecitadel/adonisjs-girouette
node ace configure @softwarecitadel/adonisjs-girouette

Usage

// CustomersController.ts
import { Get, Post, Patch, Delete, Middleware } from "@ioc:SoftwareCitadel/Girouette"

export default class CustomersController {
  @Get("/customers", "customers.index")
  public async index(/* ... */) {
    // ...
  }
  
  @Get("/customers/create", "customers.create")
  @Middleware("auth")
  public async create(/* ... */) {
    // ...
  }
  
  @Post("/customers", "customers.store")
  @Middleware("auth")
  public async store(/* ... */) {
    // ...
  }
  
  @Get("/customers/:id", "customers.show")
  @Where("id", /^[0-9]+$/)
  public async show(/* ... */) {
    // ...
  }

  @Get("/customers/:id/edit", "customers.edit")
  @Where("id", /^[0-9]+$/)
  @Middleware("auth")
  public async edit(/* ... */) {
    // ...
  }

  @Patch("/customers/:id", "customers.update")
  @Where("id", /^[0-9]+$/)
  @Middleware("auth")
  public async update(/* ... */) {
    // ...
  }

  @Delete("/customers/:id", "customers.destroy")
  @Where("id", /^[0-9]+$/)
  @Middleware("auth")
  public async destroy(/* ... */) {
    // ...
  }
}

Resourceful controller

// CustomersController.ts
import { Resource } from "@ioc:SoftwareCitadel/Girouette"

@Resource("/customers", "customers")
export default class CustomersController {
  public async index(/* ... */) {
    // ...
  }
  
  @Middleware("auth")
  public async create(/* ... */) {
    // ...
  }
  
  @Middleware("auth")
  public async store(/* ... */) {
    // ...
  }
  
  public async show(/* ... */) {
    // ...
  }

  @Middleware("auth")
  public async edit(/* ... */) {
    // ...
  }

  @Middleware("auth")
  public async update(/* ... */) {
    // ...
  }

  @Middleware("auth")
  public async destroy(/* ... */) {
    // ...
  }
}

About

Girouette is a AdonisJS package providing decorators to handle routing.

Resources

License

Contributing

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published