appRoutes

tcmts.cli.pack.appRoutes · #otavmgzz · term · runs anywhere

An app's plain HTTP routes: the functions in its namespace's http namespace (registry.http.oauth.client), shipped with it as http.… (http.oauth.client), for tcm start --http http.oauth=/oauth to serve. Tests aren't routes.

import type { Codebase } from "#codebase/tcmts/cli/codebase";
import type { NameRow } from "#codebase/tcmts/store";

export function appRoutes(cb: Codebase, app: string): NameRow[] {
  const ns = app.includes(".") ? `${app.slice(0, app.lastIndexOf("."))}.http.` : "http.";
  return cb.store
    .names()
    .filter(
      (n) =>
        n.kind === "term" &&
        n.path.startsWith(ns) &&
        !n.path.slice(n.path.lastIndexOf(".") + 1).startsWith("test"),
    );
}

uses

used by