Skills DirectorySkills Directory
SkillsLearnSecurityCategoriesDocsCommunityBlog
Sign InSubmit Skill
Skills Directory

Security-tested agent skills for Claude, coding agents, and AI workflows.

Directory

  • Browse Skills
  • All Skills A–Z
  • Claude Skills
  • Claude Code Skills
  • Agent Skills
  • Categories
  • Submit a Skill

Learn

  • Learn Hub
  • Install Claude Skills
  • Write SKILL.md
  • Skills vs MCP
  • Directories Compared

Security

  • Security
  • Methodology
  • Secure Claude Skills
  • Security Badges

Company

  • About
  • Community
  • Blog
  • API Docs
  • Advertise

2026 Skills Directory. All rights reserved.

Back to skills

Server Api

ASecurity

Implement HTTP entrypoint protocols with @owlmeans/server-api handlers<Context>().body(), params(), request(), and uploadedFile(). Load before writing an API handler.

3 stars
0 votes
0 copies
0 views
Added 9/22/2026
developmentapi

Works with

cliapi

Security Analysis

A100/100

Scanned 9/22/2026

Install to Claude Code

$npx -y skills add owlmeans/common --skill server-api --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Server Api?

Add the live security badge to your README — it updates automatically with every re-scan.

Security grade badge for Server Api
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/owlmeans-server-api/badge)](https://www.skillsdirectory.com/skills/owlmeans-server-api)

More formats (shields.io, HTML) on the badges page.

Download Zip
Files
SKILL.md
---
name: server-api
description: Implement HTTP entrypoint protocols with @owlmeans/server-api handlers<Context>().body(), params(), request(), and uploadedFile(). Load before writing an API handler.
user-invocable: false
---

# @owlmeans/server-api

**Install:** `bun add @owlmeans/server-api@^0.1.18-rc.34`

Make handlers from the protocol declaration so input and output types stay coupled to the shared
contract:

```ts
const api = handlers<AppContext>()

const create = api.body(projectProtocols.create, async (body, context, request) =>
  context.projects.create(body, request.auth)
)

const get = api.params(projectProtocols.get, async ({ id }, context) =>
  context.projects.get(id)
)

const search = api.request(projectProtocols.search, async (request, context) =>
  context.projects.search(request.query)
)

export const serverBindings = [
  bind(projectProtocols.create, create),
  bind(projectProtocols.get, get),
  bind(projectProtocols.search, search),
]
```

`body` and `params` are available only for a protocol declaring that section. `request` works for
any protocol and receives all its typed sections plus request metadata. A successful callback
return resolves the entrypoint with `EntrypointOutcome.Ok`; a thrown error rejects it.

## Wrap exactly once

A handler is wrapped by `handlers<Context>()` exactly once — either shape above (create the bound
handler and bind it directly) is correct on its own. Never combine them: a handler module that
already exports a bound handler must be bound directly, not wrapped again where it is bound.

```ts
// WRONG — bound once in the handler module, wrapped a second time here
export const create = api.body(projectProtocols.create, async (body, context) => ...)
bind(projectProtocols.create, api.body(projectProtocols.create, create))
```

`tsc` rejects the double wrap (`TS2345 "Argument of type 'BoundEntrypointHandler<…>' is not
assignable"`). At runtime, `body`/`params`/`request` return an already-bound handler for the SAME
protocol unchanged, with a one-time warning; anything else that is not a plain function fails only
that one route with `HandlerMisconfiguredError`, instead of the opaque
`TypeError: handler is not a function`.

## The status a thrown error answers

A thrown error (or a rejected response) is answered with the marshalled `ResilientError` as the
body and a status from `errorStatus(error)` (`./utils`), resolved in this order:

| Error | Status |
|---|---|
| `AuthForbidden`, `AccessError` or a subclass — by class or registered type name | 403 |
| `AuthorizationError`, `AuthFailedError` or a subclass — by class or registered type name | 401 |
| a class declaring `static httpStatus` as an integer 400–499 | that status |
| anything else, including a declaration outside 400–499 | 500 |

- **A refusal of the caller's condition declares its status; a fault declares nothing.** 400 a
  malformed request, 402 an unpaid balance or plan, 404 an addressed target that does not exist
  (or is another organization's), 409 a target whose current state conflicts, 422 content or a body
  that is understood and refused — and a missing configuration, a broken peer, a timeout or a bug
  stays 500, because monitoring, logs, proxies and retry logic read a 5xx as the server failing.
  The table and the leaf-class rule are the `error` skill's.
- Declare it on the class: `public static httpStatus = 409` (`override` only when an ancestor
  already declares one). The declaration is structural — the package declaring an error never
  imports `@owlmeans/server-api` — and a static property is inherited, so a subclass answers its
  nearest declaring ancestor's status and redeclares to change it.
- The auth branches win over a declaration, in that order (`AuthForbidden extends
  AuthorizationError`, so 403 is tested first). An entitlement or permission refusal extends
  `AuthForbidden` rather than declaring 403.
- `handleError` resolves the status on the error AS THROWN first, and asks the ENSURED
  (`ResilientError.ensure`) error only when that answers 500. The thrown object is the one whose
  class is certainly what was raised; the rebuild is what gives a status to a marshalled error that
  crossed a hop as a plain `Error`. `ensure` returns an error from any `@owlmeans/error` copy
  untouched, so the body keeps the thrown class's `type` (`AuthFailedError|||api:auth:…`) even in a
  process holding duplicate module copies (`bun --preserve-symlinks`). `executeResponse` ensures
  nothing and answers the rejected error's status. `@owlmeans/server-socket` answers an upgrade
  through the same `handleError`.
- An auth family is recognised by `instanceof` OR by an exact registered type name — the instance's
  `type` or any static `typeName` on its constructor chain — so a class from another module copy
  answers the same status. Match whole names, never substrings: a subclass's `typeName` does not
  reliably embed its parent's (`EntitlementRefusal` extends `AuthForbidden`). A declared
  `httpStatus` is a structural static read and survives duplicate copies as it is.
- The status never changes what a client rebuilds: `@owlmeans/api` rehydrates the class from the
  body for any non-2xx answer, so a caller branches on the class, never on the number. Nothing in
  the framework treats a 404 specially — a missing route is a Fastify JSON body the client turns
  into `ApiClientError('404')`, a refusal is a marshalled string rebuilt as its class.

`uploadedFile(request)` is the Fastify multipart boundary. Keep raw Fastify access there rather
than reaching through `request.original` in application code.

## Error exposure

`handleError` always assigns an incident UUID, attaches it to the logged error and returns it in the
`X-Incident-ID` response header (exposed through CORS). A production response body contains only
that id; an explicit `cfg.http.errors.exposure = 'development'` uses the typed marshalled form with
message and stack. Keep the default production-safe, and tell a client to report the incident id.

Do not use unbound compatibility handler wrappers. For a WebSocket route use
`@owlmeans/server-socket`'s `connection(protocol, callback)`.

Attribution

owlmeansowlmeans
View sourceMore from owlmeans →
SSkills DirectorySkills Directory

Ship a skill? Prove it's safe.

Free 120-pattern security scan, letter grade, and an embeddable README badge.

Submit a skill

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

Comments (0)

No comments yet. Be the first to comment!

SSkills DirectorySkills Directory

Ship a skill? Prove it's safe.

Free 120-pattern security scan, letter grade, and an embeddable README badge.

Submit a skill

Related Skills

Browser Extension Developer

Use this skill when developing or maintaining browser extension code in the `browser/` directory, including Chrome/Firefox/Edge compatibility, content scripts, background scripts, or i18n updates.

284072 votes

Seo Optimizer

SEO optimization with keyword analysis, readability assessment, technical validation, content quality. Use for search rankings, blog posts, content audits, or encountering keyword density, readability scores, meta tags, schema markup errors.

2192 votes

Google Official Seo Guide

Official Google SEO guide covering search optimization, best practices, Search Console, crawling, indexing, and improving website search visibility based on official Google documentation

1862 votes

Tanstack Start

Build a full-stack TanStack Start app on Cloudflare Workers from scratch — SSR, file-based routing, server functions, D1+Drizzle, better-auth, Tailwind v4+shadcn/ui. Use whenever the user mentions TanStack Start, asks to scaffold a full-stack Cloudflare app with SSR, wants an SSR dashboard, or asks for a React 19 + Cloudflare Workers app with file-based routing and server functions — even if they don't name TanStack Start specifically. No template repo — Claude generates every file fresh per ...

9881 votes

Pentest

PTES-aligned adversarial security audit for backend, frontend, and mobile applications. Produces a CVSS-scored Hacker Report with verified PoCs and phased remediation.

5491 votes
View all in development →