Skip to content

REST v1 API

Open in ChatGPTOpen in Claude

The rest-v1 starter is the full-breadth default. It composes an ApiStack around the AtfRestApi construct and drives every route from typed config in config/lambdas.ts.

A single API route is an ApiLambdaConfig. This is the POST /items route from the framework’s example-rest-full, included from source:

export const createItemConfig: ApiLambdaConfig = {
kind: "api",
name: "create-item",
entry: "lambdas/modules/items/api/create/index.ts",
description: "Create an item",
method: "POST",
path: "/items",
authorizer: "cognito",
// Phase 3N: also require an API key (orthogonal to the cognito authorizer).
apiKey: true,
};

method + path describe the route; authorizer selects the auth mode (see The Auth Matrix); apiKey: true additionally requires an x-api-key header. The entry is resolved relative to the project root and bundled by the lambda factory.

axs add lambda writes the handler, the config, a test stub, and the registry import in one step:

Terminal window
axs add lambda items/create --kind api --method POST --path /items

See the axs add lambda reference for every flag.

A single warm Lambda can serve several related routes (one function, one IAM role, one log group) via defineApiLambda + basePath. Each routes[] entry is a relative { method, path, authorizer? }; the per-route authorizer falls back to the config-level authorizer, then the kind default (cognito):

import { defineApiLambda } from "@axis-tech-co/axis-core";
export const authConfig = defineApiLambda({
name: "auth",
entry: "lambdas/modules/auth/api/handler/index.ts",
description: "Auth on one warm function",
basePath: "/auth",
routes: [
{ method: "POST", path: "login", authorizer: "none" },
{ method: "POST", path: "register", authorizer: "none" },
{ method: "POST", path: "refresh", authorizer: "cognito" },
],
});

Logical IDs are derived from (path, verb), so a fat lambda produces the identical CloudFormation method IDs as declaring the same routes separately — promoting a single-route config to a one-entry routes[] on the same path is zero-drift. You can also author routes non-interactively with the repeatable --route / --base-path flags (see axs add lambda).

© 2026 Axis Tech. Powered by axis-tech.co.