cloudflare / cloudflare/chanfana

Base Auto Endpoints: add context to custom serializer

Open
#258 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
TypeScript
Stars
766
Forks
70
Avg merge
25m
Merged PRs (30d)
4

Description

The `serializer` options currently just passes in the object to transform/serialize.

```
export type Model = {
tableName: string;
schema: AnyZodObject;
primaryKeys: Array;
serializer?: (obj: object) => object;
serializerSchema?: AnyZodObject;
};
```

but I would like to access the context (mainly request params) here to decide how to transform it.

Rationale is an `expand` query param that would allow me to expand some objects in the response.

Contributor guide

Open the contributing guide

Research direction

Start by locating the Model type and the serializer call sites in the Base Auto Endpoints implementation. Trace how request parameters are available, decide what context the serializer should receive, and verify that an expand query parameter can change the serialized response without breaking existing serializers.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
api, backend
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.