Girouette

Installation

How to install and configure Girouette in your AdonisJS application

Installation

Getting Girouette up and running in your AdonisJS v7 application is straightforward.

Quick Install

Install via AdonisJS CLI

The recommended way to install Girouette is using the AdonisJS add command:

node ace add @adonisjs-community/girouette

Start Using Decorators

Import and use decorators in your controllers:

import { Get } from '@adonisjs-community/girouette'

export default class HomeController {
  @Get('/') 
  async index() {
    return { message: 'Hello World!' }
  }
}

Manual Installation

If you prefer manual setup:

npm install @adonisjs-community/girouette
yarn add @adonisjs-community/girouette
pnpm add @adonisjs-community/girouette

Then run the configure command:

node ace configure @adonisjs-community/girouette

Configuration

The configuration file is created at config/girouette.ts:

config/girouette.ts
import { defineConfig } from '@adonisjs-community/girouette'

export default defineConfig({
  /**
   * Glob pattern for controller discovery
   * By default, scans all files ending with _controller.ts in the app folder
   */
  controllersGlob: './app/**/*_controller.ts', 
})

Controller Discovery

By convention, Girouette recursively scans all files in the ./app folder that end with _controller.ts. You can customize this behavior:

export default defineConfig({
  // Only scan specific directories
  controllersGlob: './app/controllers/**/*_controller.ts',
})
export default defineConfig({
  // Include multiple patterns
  controllersGlob: './app/{controllers,modules}/**/*_controller.ts',
})

Make sure your controller files follow the naming convention (*_controller.ts) or update the glob pattern to match your file naming.

Provider Registration

The provider should be automatically registered in your adonisrc.ts. If not, add it manually:

adonisrc.ts
import { defineConfig } from '@adonisjs/core/app'

export default defineConfig({
  providers: [
    // ... other providers
    () => import('@adonisjs-community/girouette/girouette_provider'), 
  ],
})

TypeScript Configuration

Girouette uses TypeScript decorators. Ensure your tsconfig.json has the following options enabled:

tsconfig.json
{
  "compilerOptions": {
    "experimentalDecorators": true, 
    "emitDecoratorMetadata": true
  }
}

AdonisJS v7 applications already have these options enabled by default.

Verifying Installation

After installation, start your development server:

node ace serve --hmr

Create a simple controller to verify everything works:

app/controllers/health_controller.ts
import { Get } from '@adonisjs-community/girouette'

export default class HealthController {
  @Get('/health')
  async check() {
    return { status: 'ok', timestamp: new Date().toISOString() }
  }
}

Visit http://localhost:3333/health to confirm the route is working.

Next Steps

On this page