[data-reveal]{opacity:1!important;transform:none!important}
DocumentationQuick start

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:

terminal
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:

src/index.ts typescript
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:

terminal
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:

text
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.

Note

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:

terminal
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:

text
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:

  1. The core loads antelope.config.ts and resolves the module configurations.
  2. The core downloads and caches the modules the project needs.
  3. The core checks the interface dependency graph, so that every required interface has a provider.
  4. Providers publish their config variables.
  5. Modules run construct(). Each module sets up its internal state and registers its interface implementations.
  6. Modules run start(). Active work begins, and a configured HTTP provider can serve requests.

Choose the next result

GoalContinue with
Understand what connects modulesArchitecture
Add an HTTP endpointAPI routing
Publish a capability for another moduleExporting interfaces
Run modules inside an existing serverEmbedded 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.