Socket
Book a DemoInstallSign in
Socket

@softwarecitadel/adonisjs-girouette

Package Overview
Dependencies
Maintainers
1
Versions
12
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install
Package was removed
Sorry, it seems this package was removed from the registry

@softwarecitadel/adonisjs-girouette

Girouette is a AdonisJS package providing decorators to handle routing.

0.0.11
unpublished
latest
Source
npmnpm
Version published
Weekly downloads
0
Maintainers
1
Weekly downloads
 
Created
Source

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", {"*": "auth"})
export default class CustomersController {
  public async index(/* ... */) {
    // ...
  }
  
  public async create(/* ... */) {
    // ...
  }
  
  public async store(/* ... */) {
    // ...
  }
  
  public async show(/* ... */) {
    // ...
  }

  public async edit(/* ... */) {
    // ...
  }

  public async update(/* ... */) {
    // ...
  }

  public async destroy(/* ... */) {
    // ...
  }
}

You can also create a resource that is API only.

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

@Resource("/users", "users")
@ApiOnly()
export default class CustomersController {
  // ...
}

Filtering routes

You can restrict specific methods using the @Except decorator.

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

@Resource("/users", "users")
@Except(["store", "update", "destroy"])
export default class CustomersController {
  // ...
}

The opposite of @Except decorator is the @Only decorator which can be used to register only the methods you want.

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

@Resource("/users", "users")
@Only(["index", "show"])
export default class CustomersController {
  // ...
}

Keywords

adonis

FAQs

Package last updated on 23 Dec 2023

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.