CLI
Use@hile/cli when an application should start through hile start instead of a custom Node entrypoint.
Copy-Paste Example
More Examples
Template choices:Runtime And Lifecycle Notes
defineService(key, fn)registers a service factory and does not execute it.loadService(service)executes the factory on first call and returns the cached value afterwards.- The
shutdowncallback registers teardown functions; they run in LIFO order. - The container tracks dependencies when service factories call
loadService(). container.shutdown()triggers registered teardowns.@hile/bootstraploads env files first, setsNODE_ENV, imports auto-load packages, scans boot files, and installs exit hooks.@hile/logger.createLogger()returns{ logger, teardown }.@hile/ioredis.createRedis()waits forconnect.@hile/typeorm.createDataSource()initializes a TypeORMDataSource.
Anti-Patterns
- Reusing one service key for unrelated factories.
- Missing
shutdown()callbacks for network connections or servers. - Assuming TypeORM env config fills entities automatically when
TYPEORM_ENTITIESis not set. - Calling
transaction()and manually committing; the helper commits or rolls back internally.