Quick start
Create a local module, watch its lifecycle, and check development reloads before you add an HTTP server or database.
Your first project
In this tutorial, we create a project, run one module, and watch it reload. You need Node.js, Git and pnpm for the commands below. The CLI runs through npx, so no global install is required. This first application prints a message. It does not open an HTTP port.
Create a new project
Create the project from the blank TypeScript template, with every choice given as a flag:
npx @antelopejs/core project init my-project --template blank-typescript --pm pnpm --no-git-init
cd my-project
blank-typescript is the slug of the "Blank Typescript" template. The CLI installs the template dependencies and registers the local module in antelope.config.ts. The project directory contains both the application configuration and its first module. Omit the flags to choose a template and package manager interactively.
Make the module print its lifecycle
Replace the entry point of the blank module with this lifecycle example:
export function construct(): void {
console.log("Hello from my first AntelopeJS module");
}
export function start(): void {
console.log("Module started");
}
export function destroy(): void {
console.log("Module resources released");
}
construct() prepares the module. start() begins work after construction succeeds. destroy() releases resources during shutdown or reload. This example has no external resources to close.
Run the project
Start the project in development mode:
npx @antelopejs/core project dev
The template lists @antelopejs/core as a dependency, so inside the project npx runs that installed copy. Look for these module messages in the CLI output. The progress lines are left out here:
Hello from my first AntelopeJS module
Module started
These messages show that the core loaded the entry point and called its lifecycle functions. This example creates no server, timer, or other ongoing work, so without watch mode the process can exit after startup. Watch mode, in the next step, keeps it running so you can see a reload and the shutdown cleanup.
ajs project run is an alias for ajs project dev. Both commands start the project in development mode.
Enable watch mode
To reload the module when its source files change, add the --watch flag:
npx @antelopejs/core project dev --watch
Change the greeting in src/index.ts and save. The generated local source configuration runs its build command, then the core destroys and replaces the module. The cleanup message and the new greeting appear, and the CLI keeps running.
Press Ctrl+C to stop the watcher. The module's cleanup message appears before the CLI's shutdown confirmation:
Module resources released
If your own local source configuration has no build command, watch mode does not invent one. Set installCommand and reloadCommand as described in Creating a module.
What happens at startup
When you run ajs project dev, the core goes through these steps in order:
- The core loads
antelope.config.tsand resolves the module configurations. - The core downloads and caches the modules the project needs.
- The core checks the interface dependency graph, so that every required interface has a provider.
- Providers publish their config variables.
- Modules run
construct(). Each module sets up its internal state and registers its interface implementations. - Modules run
start(). Active work begins, and a configured HTTP provider can serve requests.
Choose the next result
| Goal | Continue with |
|---|---|
| Understand what connects modules | Architecture |
| Add an HTTP endpoint | API routing |
| Publish a capability for another module | Exporting interfaces |
| Run modules inside an existing server | Embedded runtime |
An interface package gives you the contract. It does not give you a running server or database. Add a provider module for the interface to the application configuration before you call it.