💡 Sept. Tip => the mountAt trilogy
Or how to customize how and where the use cases are exposed within a target.
During this month of September 2025, we'll highlight various and interesting aspects of libmodulor
.
If you remember well, a UseCase
is part of an App
, which is mounted in a Product
, which is exposed via a Target
.
The way a use case is exposed is highly inherent to the type of target.
By default, it is mounted at the fully qualified use case name (FQUCName
), which is ${AppName}_${UCName}
.
So for a CLI target, it is mounted as a command like npx my-super-cli Accounting_CreateOperation
.
And for a server target, it is mounted as an endpoint like https://my-super-server.com/api/v1/Accounting_CreateOperation
.
But in some situations, the defaults are not satisfying. For instance, if a consumer of your API expects a very specific URL, you should be able to adapt this default behavior.
In this case, you can customize it directly within the UCDef.ext
property.
const CreateOperationUCD: UCDef<CreateOperationInput, CreateOperationOPI0> = {
// ...
ext: {
// For a target that is "command" based (e.g. a CLI)
cmd: {
// The command will become `npx my-super-cli create-op`
mountAt: 'create-op',
},
// For a target that is "http" based (e.g. an API)
http: {
// The endpoint will become http://my-super-server.com/api/v2/operations/new
mountAt: '/api/v2/operations/new',
// You can also define a list of "aliases"
// which is very handy to maintain backward compatibility.
mountAlsoAt: ['/api/v1/Accounting_CreateOperation']
}
},
// ...
}
Voilà c'est tout.