IF Commons GitHub

logical/handler

Written to: 6 requirements: 6 proved, 0 partly, 0 failing, 0 with no test recorded. 0003-anyfs-serve-logical FR-010, 0003-anyfs-serve-logical FR-011, 0003-anyfs-serve-logical FR-012, 0003-anyfs-serve-logical FR-013, 0003-anyfs-serve-logical FR-014, 0003-anyfs-serve-logical FR-015

The handler: a function from a web Request to a Response that serves one AnyFS store as WebDAV on the POSIX view of it. It answers OPTIONS, GET, HEAD, PUT, DELETE, MKCOL, COPY, MOVE, PROPFIND, PROPPATCH, LOCK and UNLOCK, checks the host, the credentials and the locks before it touches the store, takes every guard of a write from the request (If-Match, If-None-Match, If) and gives it to the store as the expectation of the write where the store can hold it, and says in X-Anyfs-Fidelity how each answer was carried out. It holds no socket: a test calls it with a Request, and the server of the physical layer hosts it.

import { memoryStore } from "@intellectual-frontiers/anyfs/memory";
import { handler } from "./handler.ts";
import { noAuthentication } from "./auth.ts";
const serve = handler(memoryStore(), { authenticator: noAuthentication });
const response = await serve(new Request("http://127.0.0.1/note.txt", { method: "PUT", body: "hello" }));
response.status; // 201

Source: commons/anyfs-serve/src/logical/handler.ts

2 of 3 exports are imported by a test of the run. A test that imports an export may not call it or check what it returns.

ServeEventtype
type ServeEvent = { readonly method: string; readonly path: string; readonly status: number; readonly fidelity: string | undefined; readonly milliseconds: number };

What happened to one request: for a log, a trace or an audit, with no credential and no body.

Imported by 4 tests of the run (4 passed, 0 failed): the library's results

HandlerOptionstypeno test imports it
type HandlerOptions = { /** Who may ask. There is no default: a server that asks nobody says so with `noAuthentication… (1129 characters)
type HandlerOptions = {
  /** Who may ask. There is no default: a server that asks nobody says so with `noAuthentication`. */
  readonly authenticator: Authenticator;
  /** The host names a request may name in `Host`, without ports; the loopback names by default. */
  readonly hosts?: readonly string[];
  /** The address the server answers below, `/` by default. */
  readonly base?: string;
  readonly limits?: Limits;
  /** What to do with the files a desktop makes by itself: `allow` by default. */
  readonly junk?: Junk;
  /** Whether an empty collection is kept as an object: `markers` by default. */
  readonly directories?: Directories;
  /** What to do with a name that is not NFC: turn it into NFC (the default) or refuse it. */
  readonly unicode?: Unicode;
  /** Whether LOCK and UNLOCK are answered (class 2): on by default. */
  readonly locks?: boolean;
  /** The realm of the challenge. */
  readonly realm?: string;
  /** The time in milliseconds; the clock by default. */
  readonly clock?: () => number;
  /** Told of every request when it is answered. */
  readonly onEvent?: (event: ServeEvent) => void;
};

What the handler is told.

handlerfunction
function handler(store: Store<Viewable>, options: HandlerOptions): (request: Request) => Promise<Response>

The handler of a store.

Imported by 9 tests of the run (9 passed, 0 failed): the library's results

Titles, headings, exports, tables, columns and requirements. Esc closes.