🚧 AvleonJs is in active development and not ready for production use.

Avleon Commands

Useful commands

Install the CLI globally, or run it with npx:

npm i -g @avleon/cli

Command Overview

CommandAliasDescription
newCreate a new application
serveStart the dev server with watch + rebuild
buildCompile using tsconfig.build.json
make:modelm:mCreate a model or TypeORM entity
make:controllerm:cCreate a controller
make:servicem:sCreate a service
make:configm:cnfCreate a config class
make:middlewarem:mlwrCreate a middleware

Every make:* command takes -f / --force to overwrite an existing file.

Application

npx @avleon/cli new myapi

You are prompted for a package manager and optional features — OpenAPI docs, CORS, TypeORM, Knex and Scalar UI. Then:

cd myapi
npm run start:dev

Development Server

npx avleon serve

Compiles src/ with SWC into dist/, starts the app and restarts it on change. The entry point comes from avleon.entry in package.json, falling back to main.

Controller

npx avleon make:controller user
# shorthand
npx avleon m:c user

Pass -r for a full REST skeleton, and -m <model> to bind it to a model:

npx avleon m:c user -m user -r

With -m, the matching service is generated in src/services and the controller delegates to it. Add --orm to back that service with a TypeORM repository.

Use -rt <dir> to place the file under a different directory, and --base-path to emit @ApiController without a route prefix.

Service

npx avleon make:service user

A resource service uses an in-memory Collection by default:

npx avleon make:service user -m user -r

Add --orm for one backed by a TypeORM repository:

npx avleon make:service user -m user -r --orm

Model

# plain class
npx avleon make:model user

# TypeORM entity
npx avleon m:m user --orm

Middleware

npx avleon make:middleware auth

Generates a class extending AvleonMiddleware:

src/middlewares/auth.middleware.ts
import { AppMiddleware, AvleonMiddleware, IRequest, IResponse } from '@avleon/core';

@AppMiddleware
export class AuthMiddleware extends AvleonMiddleware {
  async invoke(req: IRequest, res?: IResponse) {
    // your logic goes here
    return req;
  }
}

Config

npx avleon make:config jwt

Generates a class extending AvleonConfig and registered with @AppConfig:

src/config/jwt.config.ts
import { AppConfig, AvleonConfig, Environment } from '@avleon/core';

@AppConfig
export class JwtConfig extends AvleonConfig {
  config(env: Environment) {
    return {};
  }
}

Build

npx avleon build

Removes dist/ and compiles the project with tsconfig.build.json.