Skip to content

Query parameters ​

@Query() adds field values to the URL query string. Use replaceAt to separate TypeScript names from wire names, and choose array serialization to match the server.

Example ​

ts
import { 
Get
,
JinFrame
,
Query
} from 'jin-frame';
@
Get
({
host
: 'https://api.example.com',
path
: '/search',
}) class
ExampleFrame
extends
JinFrame
{
// Rename a TypeScript field to the API's query parameter. @
Query
({
replaceAt
: 'q' })
declare readonly
search
: string;
// Serialize arrays as repeated bracketed query keys. @
Query
({
keyFormat
: 'brackets' })
declare readonly
tags
?: string[];
} // Build the request without contacting the placeholder server. const
frame
=
ExampleFrame
.
of
({
search
: 'hello world',
tags
: ['red', 'blue'] });
const
request
=
frame
.
_request
();
console
.
log
(
request
.
url
);

Options ​

OptionTypeDefaultDescription
replaceAtstringField nameQuery parameter name sent to the server.
encodebooleantrueApply URI encoding to query values.
commabooleanfalseJoin array values with commas.
separator',' | ' ' | '|'undefinedArray separator; takes precedence over comma.
keyFormat'brackets' | 'indices' | 'one-indices'undefinedArray key format; unspecified repeats the unmodified key.
bit.enablebooleanfalseCombine numeric arrays using bitwise OR.
bit.withZerobooleanfalseInclude a bitwise result even when it is zero.
formattersFormatter | Formatter[]undefinedTransform values before serialization.
cacheKeyExcludebooleanfalseExclude from dedupe identity without omitting transmission.

Configure bit as { enable: true, withZero: false }.

Array serialization ​

OptionShape
keyFormat: 'brackets'tags[]=red&tags[]=blue
keyFormat: 'indices'tags[0]=red&tags[1]=blue
keyFormat: 'one-indices'tags[1]=red&tags[2]=blue
comma: trueComma-joined values.
separator: ' ', separator: '|'Space- or pipe-joined values.

URL text percent-encodes reserved characters. Inspect decoded query entries when comparing logical values instead of relying on display encoding.

Optional fields and transforms ​

Absent optional fields are omitted. Empty string, zero, and false are values; do not assume they behave like undefined. formatters can normalize strings or format Dates before encoding. cacheKeyExclude: true affects deduplication identity, not whether a value is transmitted.

See formatters and deduplication.