Basic
An example showcasing the mechanisms of libmodulor in one single executable file.
This is the perfect example to have an overview of the most important primitives of libmodulor.
In one single file, we declare an App, a UseCase, a Product and a Target.
Then we initiates the use case and submit it to show how validation works.
Get
git clone git@github.com:c100k/libmodulor.git
pnpm install
Build
./scripts/examples/build.sh
Run
Open your Terminal Emulator.
# with node
(cd dist-examples/products/Basic && node index.js)
# with bun
(cd examples/products/Basic && bun index.ts)
Note how it works with both Node and Bun without having to override any implementations in the container.
This is due to the high modularity of libmodulor and the great work the bun team is doing to support the Node.js API.
You get a full output of what's going on step by step.
Declaring the App
Declaring the UseCase
Declaring the Product
Declaring the Target
Initializing i18n
Initializing the UseCase
Submitting the use case empty
❌ Oops : Your email address must be filled
Filling all the fields correctly except the email (invalid)
❌ Oops : Your email address must be a valid email address
Filling a valid email
✅ Use case executed successfully
💾 Persisted record in InMemoryUCDataStore
{
aggregateId: "8ab239c6-8cab-446e-9298-b13596807501",
appName: "Event",
createdAt: 2025-11-16T21:32:18.585Z,
data: null,
executionMode: "user",
id: "d095be35-f6cb-45db-a9a3-8e536153db8d",
input: {
email: "dexter@caramail.com",
firstname: "Dexter",
lastname: "Morgan",
},
name: "Register",
organizationId: null,
userId: null,
}
📓 Summary with fields from I18n/WordingManager
Your registration # : 8ab239c6-8cab-446e-9298-b13596807501
Your email address : dexter@caramail.com
Your wonderful firstname : Dexter
Your awesome lastname : Morgan
Play with the example, add features, break it 🙂.