Skip to content

jin-frame / processors/default-option/getDefaultBodyFieldOption / getDefaultBodyFieldOption

Function: getDefaultBodyFieldOption()

getDefaultBodyFieldOption(option?): IBodyFieldOption

Defined in: packages/jin-frame/src/processors/default-option/getDefaultBodyFieldOption.ts:4

Parameters

option?

Partial<IBodyFieldOption> |

{ cacheKeyExcludePaths?: string[]; encode?: boolean; formatters?: TSingleBodyFormatter | TSingleBodyFormatter[]; key?: string; replaceAt?: string; }

cacheKeyExcludePaths?

string[]

When paths are provided in this option, they will be excluded from cache key generation. Unlike Query, Param, and Header, Body and ObjectBody use path specifications to exclude specific values.

Including values that always change (like UUIDs) in the cache reduces cache efficiency. Enable this option to exclude such fields from caching.

encode?

boolean

Do encodeURIComponent execution, this option only executed in query parameter

formatters?

TSingleBodyFormatter | TSingleBodyFormatter[]

formatter configuration, use convert date type or transform data shape

formatters field only work when have valid input type.

formatters fields operate in order of string formatter, dateTime formatter. So You can change a string to JavaScript Date instance using by string formatter and a converted Date instance to string using by dateTime formatter.

Remarks

If you use the string formatter to change to JavaScript Date instance and then do not change to a string, the formatters setting is: automatically convert to iso8601 string

Example

ordered example.

{
findFrom: 'data.more.birthday',
string: (value: string) => parse(value, "yyyy-MM-dd'T'HH:mm:ss", new Date()),
dateTime: (value: Date) => format(value, 'yyyy-MM-dd HH:mm:ss'),
}

key?

string

The field key name

replaceAt?

string

If you want to create depth or rename on field of body set this option dot separated string. See below,

Example

ts
`data.test.ironman` convert to `{ data: { test: { ironman: "value here" } } }`

Returns

IBodyFieldOption