Axios transformer/interceptor that converts snake_case/camelCase
MIT License
Full Changelog: https://github.com/mpyw/axios-case-converter/compare/v1.1.0...v1.1.1
Published by mpyw 9 months ago
Full Changelog: https://github.com/mpyw/axios-case-converter/compare/v1.1.1...v1.1.2
Published by mpyw 10 months ago
Full Changelog: https://github.com/mpyw/axios-case-converter/compare/v1.1.0...v1.1.1
Published by mpyw over 1 year ago
Published by mpyw over 1 year ago
Published by mpyw about 2 years ago
Published by mpyw about 2 years ago
Don't accept class instances as transformable by mpyw 路 Pull Request #50 路 mpyw/axios-case-converter
Warning BREAKING CHANGE
isPlainObject
logic has been changed. Now it doesn't try to convert class instances, such asmoment()
Published by mpyw about 2 years ago
The two critical problems are:
- The value returned from
axios-mock-adapter
mock definitions must be anAxiosHeaders
object, otherwise the instance reference will be changed.axios
does not exposeAxiosHeaders
constructor.While not a bug, axios@v1 still has a problem for testability. In this PR, I managed to get the test passed via dirty hacks.
Although #47 was not a bug, still there are problems.
Published by mpyw about 2 years ago
feat!: Support Axios v1 by siketyan 路 Pull Request #46 路 mpyw/axios-case-converter
Warning BREAKING CHANGE: CreateAxiosRequestTransformer now must return AxiosRequestTransformer instead of AxiosResponseTransformer.
Also please have a look at the following issue:
Published by mpyw about 3 years ago
AxiosTransformer
-> AxiosRequestTransformer
/AxiosResponseTransformer
Published by mpyw over 3 years ago
tslib
will be installed from now on.
Published by mpyw over 4 years ago
Published by mpyw over 4 years ago
[BC] Major Refactoring by mpyw 路 Pull Request #26 路 mpyw/axios-case-converter
Resolves #23.
Breaking Changes
Renamed Options
converters.snakeRequest
->caseMiddleware.requestTransformer
converters.camelResponse
->caseMiddleware.responseTransformer
converters.snakeParams
->caseMiddleware.requestInterceptor
Renamed Files
transform.ts
->transformers.ts
index.ts
->middleware.ts
andindex.ts
Renamed or Removed Exports
- The following exports in
index.ts
are renamed or removed. Please export them frommiddleware.ts
instead, using their new names.
snakeParams
-> REMOVEDsnakeRequest
-> REMOVEDcamelResponse
-> REMOVEDcreateSnakeParams
->createSnakeParamsInterceptor
inmiddleware.ts
createSnakeRequest
->createSnakeRequestTransformer
inmiddleware.ts
createCamelResponse
->createCamelResponseTransformer
inmiddleware.ts
- The following exports in
transformers.ts
are renamed or removed.
- default -> REMOVED
snake
-> REMOVEDcamel
-> REMOVEDheader
-> REMOVEDcreateTransform
->createObjectTransformer
createTransformOf
->createObjectTransformerOf
createTransforms
->createObjectTransformers
- The following exports in
decorators.ts
are removed.
preserveArrayBrackets
-> REMOVEDRenamed, Removed or Changed Types
String Transformer Related
Transformer
->CaseFunction
Transformers
->CaseFunctions
Transformers
entries are previously all optional, butCaseFunctions
ones are all required.Partial<CaseFunctions>
is currently used instead of previousTransformers
.Object Transformer Related
TransformOptions
->ObjectTransformerOptions
TransformUsingCallback
-> REMOVEDTransform
->ObjectTransformer
CreateTransform
->CreateObjectTransformer
CreateTransformOf
->CreateObjectTransformerOf
CreateTransforms
->CreateObjectTransformers
Axios Case Middleware Related
ConverterOptions
->AxiosCaseMiddlewareOptions
ApplyConvertersOptions
->ApplyCaseMiddlewareOptions
New Features
caseOptions
optionsBy default,
{ stripRegexp: /[^A-Z0-9[\]]+/gi }
is used as defaultchange-case
function options. This preserves[]
chars in object keys. If you wish keeping originalchange-case
behavior, override the options.Fixed Bugs
- Prevent infinite loop when overwriting iterables
- Prevent duplicate entries
Published by mpyw over 4 years ago
Published by mpyw over 4 years ago
Published by mpyw over 4 years ago
Huge Refactoring by mpyw 路 Pull Request #18 路 mpyw/axios-case-converter
Overview
- Rewrite in TypeScript
- Add new feature: Exclude specific keys from automatic key conversion
- Add new feature: Customize transformer functions