jac-sv-endpoints

Designs REST API endpoints in Jac using walker and function declaration shapes.

Updated Jul 26, 2026
One-click install
npx skills add https://github.com/PMN123/trapdoor --skill jac-sv-endpoints-pmn123
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: jac-sv-endpoints
Source: https://github.com/PMN123/trapdoor/tree/main/.agents/skills/jac-sv-endpoints
Command: npx skills add https://github.com/PMN123/trapdoor --skill jac-sv-endpoints-pmn123

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Choosing and implementing the correct endpoint shape in a Jac server is error-prone: developers misuse walker:pub for simple RPC calls, hit 404/405 errors from missing entry-module imports, and mishandle the response envelope, auth visibility, and file uploads. ## Core Features & Use Cases - Endpoint shape selection: Explains when to use def:pub functions versus walker:pub walkers based on whether the endpoint actually traverses the graph. - REST surface reference: Documents /walker/<name>, /function/<name>, the standard response envelope, @restspec custom routes and methods, and multipart file uploads with UploadFile. - Pitfall guidance: Covers async endpoints, volatile _jac_id values, keyword-argument walker spawns, and the 404/405 import-registration failure mode. - Use Case: When adding a new typed CRUD endpoint to a Jac server module, use this Skill to write it as a def:pub with an explicit return type and register its name in the entry module import so it serves correctly. ## Quick Start Add a public typed list endpoint to my Jac server module and make sure it is reachable over REST.

Frequently Asked Questions about jac-sv-endpoints

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I create a REST API endpoint in Jac?

Define a `def:pub` function with an explicit return type for RPC-style endpoints, or a `walker:pub` with `has` fields as the request body and `report` values as the response. Run `jac start api.jac` and call `POST /function/<name>` or `POST /walker/<name>`.

When should I use a walker versus a function endpoint in Jac?

Use a function (`def:pub`) when the endpoint does not traverse the graph; use `walker:pub` only when the body actually walks with `visit` along edges and accumulates results. A walker without traversal adds unwrapping overhead via `result.reports[0]`.

Why does my new Jac endpoint return 404 or 405?

A 404/405 on a new endpoint means its name is missing from the entry module's import statement. Adding a `def:pub` to an already-imported module still fails until the new name is explicitly added to the entry import.

How do I handle file uploads in a Jac server endpoint?

Import `UploadFile` from `http` and declare a `has file: UploadFile` field on a walker; it is classified as a multipart file parameter. Use the ambient `store()` builtin to save the file to local disk or an S3 backend.

Does Jac support custom HTTP methods and paths for endpoints?

Yes, the `@restspec` decorator with `HTTPMethod` lets you set custom methods and paths like `/users/{user_id}/orders` on both walkers and functions. Parameters are classified as path, file, query, or body based on the route and method.