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/girouetteStart 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/girouetteyarn add @adonisjs-community/girouettepnpm add @adonisjs-community/girouetteThen run the configure command:
node ace configure @adonisjs-community/girouetteConfiguration
The configuration file is created at 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:
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:
{
"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 --hmrCreate a simple controller to verify everything works:
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
- Basic Routing - Learn about HTTP method decorators
- Route Groups - Organize routes with groups
- Resources - Create RESTful resource controllers