
Security News
/Research
Wallet-Draining npm Package Impersonates Nodemailer to Hijack Crypto Transactions
Malicious npm package impersonates Nodemailer and drains wallets by hijacking crypto transactions across multiple blockchains.
simple-axios-case-converter
Advanced tools
[](https://www.npmjs.com/package/simple-axios-case-converter) [](https://github.com/yu
Axios request/response object key case converts snake_case/camelCase.
In many cases, the API's naming convention differs from JavaScript/TypeScript's(ex API is snake_case, JavaScript/TypeScript is camelCase), which means developers need to convert the case of object key.
This library makes it easy for developers to convert case.
Features:
data
params
object keys into snake_casedata
object keys into camelCaseWith this library, you will be free from converting from camelCase to snake_case when making a request, and from converting from snake_case to camelCase in a response.
$ npm install simple-axios-case-converter
$ yarn add simple-axios-case-converter
import axios, { AxiosResponse } from 'axios';
import axiosCaseConverter from 'simple-axios-case-converter';
interface User {
id: number;
firstName: string;
lastName: string;
fullName: string;
}
// setting simple axios case converter
axiosCaseConverter(axios);
const res: AxiosResponse<User> = await axios.get('https://example.com/api/v1/me');
// you need not convert response `data` to camelCase (typeof res.data is `User`)
console.log(res.data);
// you need not convert request `params` to snake_case
axios.get('https://example.com/api/v1/todos', { params: { onlyComplete: true } });
// you need not convert request `data` to snake_case
axios.post('https://example.com/api/v1/address', {
countryCode: 'JP',
postalCode: '123-4567',
prefecture: 'Tokyo',
city: 'Shibuya'
});
// you need not convert request `data` to snake_case
axios.patch('https://example.com/api/v1/address/123', { postalCode: '123-4567' });
// you need not convert request `data` to snake_case
axios.delete('https://example.com/api/v1/address/123', { data: { addressId: 123 } });
import axios from 'axios';
import axiosCaseConverter from 'simple-axios-case-converter';
// setting simple axios case converter
axiosCaseConverter(axios);
const res = await axios.get('https://example.com/api/v1/me');
// you need not convert response `data` to camelCase
console.log(res.data);
// you need not convert request `params` to snake_case
axios.get('https://example.com/api/v1/todos', { params: { onlyComplete: true } });
// you need not convert request `data` to snake_case
axios.post('https://example.com/api/v1/address', {
countryCode: 'JP',
postalCode: '123-4567',
prefecture: 'Tokyo',
city: 'Shibuya'
});
// you need not convert request `data` to snake_case
axios.patch('https://example.com/api/v1/address/123', { postalCode: '123-4567' });
// you need not convert request `data` to snake_case
axios.delete('https://example.com/api/v1/address/123', { data: { addressId: 123 } });
Note that you should be require('...').default
.
const axios = require('axios');
const axiosCaseConverter = require('simple-axios-case-converter').default;
// setting simple axios case converter
axiosCaseConverter(axios);
// after, the implementation is the same as the ES Module implementation
axiosCaseConverter: (axios, options)
-> { requestInterceptorId: number, responseInterceptorId: number }
Optional
Type: object
Optional
Type: Array<string | RegExp>
Exclude keys from being snake-cased at request params
and data
.
Optional
Type: Array<string | RegExp>
Exclude keys from being camle-cased at response data
.
There is a library, axios-case-converter
, which provides similar functionality, but the differences from that library are as follows.
Simple
Various options can be specified for axios-case-converter
, but that is also the flip side of complexity.
This library is very simple and simply converts request(data
, params
) and response(data
) cases to sanke_case/camelCase.
No side effects
The axios-case-converter
overrides axios.defaults
, which may cause unexpected side effects.
This library is simpler and safer because it uses the interceptor
and does not rewrite the default config.
Easily remove the case conversion feature
Since axios-case-converter
overwrites axios.defaults
(axios instance default config), if you want to remove axios-case-converter
functionality, you need to update axios.defaults
again and will have a hard time.
Since this library uses interceptor
, you can easily disable the functionality of this library by eject
as follows.
const { requestInterceptorId, responseInterceptorId } = axiosCaseConverter(axios);
axios.interceptors.request.eject(requestInterceptorId);
axios.interceptors.response.eject(responseInterceptorId);
[1.0.5] - 2023-10-23
FAQs
[](https://www.npmjs.com/package/simple-axios-case-converter) [](https://github.com/yu
The npm package simple-axios-case-converter receives a total of 9 weekly downloads. As such, simple-axios-case-converter popularity was classified as not popular.
We found that simple-axios-case-converter demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
/Research
Malicious npm package impersonates Nodemailer and drains wallets by hijacking crypto transactions across multiple blockchains.
Security News
This episode explores the hard problem of reachability analysis, from static analysis limits to handling dynamic languages and massive dependency trees.
Security News
/Research
Malicious Nx npm versions stole secrets and wallet info using AI CLI tools; Socket’s AI scanner detected the supply chain attack and flagged the malware.