Suffix Configuration
Suffix configuration allows you to customize how class names are generated when using asena generate commands.
What are Suffixes?
Suffixes are text strings automatically appended to class names during component generation:
| Input | Default Suffix | Result |
|---|---|---|
User | Controller | UserController |
Auth | Service | AuthService |
Logger | Middleware | LoggerMiddleware |
Database | Config | DatabaseConfig |
Chat | Namespace | ChatNamespace |
Configuration File
Suffix settings are stored in .asena/config.json, which is automatically created by asena create or asena init:
{
"adapter": "hono",
"suffixes": true
}Backward Compatibility
If your .asena/config.json doesn't include a suffixes field, all components will use default suffixes (equivalent to "suffixes": true).
Default Suffixes
| Component Type | Default Suffix |
|---|---|
| Controller | Controller |
| Service | Service |
| Middleware | Middleware |
| Config | Config |
| WebSocket | Namespace |
Configuration Options
The suffixes field supports three value types:
Boolean (Global Setting)
{
"adapter": "hono",
"suffixes": true // Use all default suffixes
}{
"adapter": "hono",
"suffixes": false // No suffixes at all
}Object (Granular Control)
{
"adapter": "hono",
"suffixes": {
"controller": true, // Use default (Controller)
"service": false, // No suffix
"middleware": "MW", // Custom suffix
"config": true, // Use default (Config)
"websocket": "Socket" // Custom suffix
}
}Each component type accepts:
true→ Use default suffixfalse→ No suffix"CustomString"→ Custom suffixundefined→ Fallback to default suffix
Examples
Global Boolean
{
"adapter": "hono",
"suffixes": true
}asena g c User # → UserController.ts
asena g s Auth # → AuthService.ts
asena g m Logger # → LoggerMiddleware.ts{
"adapter": "hono",
"suffixes": false
}asena g c User # → User.ts
asena g s Auth # → Auth.ts
asena g m Logger # → Logger.tsGranular Control
{
"adapter": "hono",
"suffixes": {
"controller": true,
"service": "Svc",
"middleware": false
}
}asena g c User # → UserController.ts (true → default)
asena g s Auth # → AuthSvc.ts (custom)
asena g m Logger # → Logger.ts (false → no suffix)
asena g config DB # → DBConfig.ts (undefined → default)Best Practices
❌ Things to Avoid
Invalid TypeScript Identifiers
// ❌ Invalid - Contains special characters
{
"controller": "Ctrl-",
"service": "Svc_",
"middleware": "Mid@ware"
}Suffixes must be valid TypeScript class name segments (letters and numbers only).
Empty Strings
// ❌ Invalid - Empty string
{
"controller": "",
"service": ""
}Use false instead of empty strings to disable suffixes.
Configuration Comparison
| Config Value | asena g c User Result |
|---|---|
undefined (no config) | UserController.ts |
true (global) | UserController.ts |
false (global) | User.ts |
{ controller: true } | UserController.ts |
{ controller: false } | User.ts |
{ controller: "Ctrl" } | UserCtrl.ts |
{} (empty object) | UserController.ts |
Manual Configuration
Edit .asena/config.json directly to modify suffix settings:
nano .asena/config.json
# or
code .asena/config.jsonExample:
{
"adapter": "hono",
"suffixes": {
"controller": true,
"service": "Svc",
"middleware": false
}
}After saving, generate components immediately:
asena g c Product # → ProductController.ts
asena g s Payment # → PaymentSvc.ts
asena g m Auth # → Auth.tsNo Restart Required
Configuration changes are applied immediately.
Related Commands
# Create new project with suffix config
asena create my-project
# Add config to existing project
asena init
# Generate components
asena g c Product # Controller
asena g s Auth # Service
asena g m Logger # Middleware
asena g config Database # Config
asena g ws Chat # WebSocketRelated Documentation
- CLI Configuration - Complete CLI configuration reference
- CLI Commands - Available CLI commands
- Controllers - Controller patterns
- Services - Service patterns
- Middleware - Middleware patterns
Next Steps:
- Explore CLI Commands to start generating components
- Learn about Controllers and other components