feathers-schemalisted
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