← ClaudeAtlas

feathers-schemalisted

Define, validate, and secure a FeathersJS v5 data model with TypeBox schemas and the four resolver kinds (result, data, query, external). Use whenever the user is working on a Feathers <name>.schema.ts file, adding or changing a field, deriving TypeScript types from a schema, validating request data or query strings, hiding sensitive fields (like passwords) from API responses, populating associations / virtual properties, hashing passwords, setting defaults like createdAt, or restricting which records a user can query. Trigger on mentions of TypeBox, Type.Object, getValidator, resolve(), querySyntax, Static, $id, "validate", "schema", or "resolver" in a Feathers context.
hassan4702/feathers-plugin · ★ 3 · API & Backend · score 74
Install: claude install-skill hassan4702/feathers-plugin
# FeathersJS Schemas & Resolvers Schemas and resolvers are database-independent. A **schema** (TypeBox) defines shape, derives the TS type, and validates. A **resolver** transforms property values against the hook context. They are applied through the `schemaHooks` registered in the service file (see `feathers-service`). ## The four kinds — what each is for - **Result** (`<name>Resolver`): shapes data being returned; the place to populate associations / virtual properties. - **Data** (`<name>DataResolver`): runs on `create`/`update`/`patch` data before saving; set defaults, computed values, hash passwords, stamp `createdAt`. - **Query** (`<name>QueryResolver`): validates/coerces the query string and is the right place to **restrict which records a user may touch** (row-level security). - **External** (`<name>ExternalResolver`): produces the safe, outward-facing version — **hide sensitive fields here** (e.g. `password`). ## Defining the schema ```ts import { resolve, virtual } from '@feathersjs/schema' import { Type, getValidator, querySyntax } from '@feathersjs/typebox' import type { Static } from '@feathersjs/typebox' import type { HookContext } from '../../declarations' import { dataValidator, queryValidator } from '../../validators' export const messageSchema = Type.Object( { id: Type.Number(), // MongoDB: _id: ObjectIdSchema() text: Type.String(), createdAt: Type.Number(), userId: Type.Number(), user: Type.Ref(userSchema) // assoc