messaging-api-common
Helpers for common usages in Messaging API clients
Table of Contents
Installation
npm i --save messaging-api-common
or
yarn add messaging-api-common
Usage
Case Convertors:
const {
snakecase,
snakecaseKeys,
snakecaseKeysDeep,
camelcase,
camelcaseKeys,
camelcaseKeysDeep,
pascalcase,
pascalcaseKeys,
pascalcaseKeysDeep,
} = require('messaging-api-common');
snakecase('fooBar');
snakecaseKeys({ fooBar: true });
snakecaseKeysDeep({ fooBar: { barFoo: true } });
camelcase('foo_bar');
camelcaseKeys({ foo_bar: true });
camelcaseKeysDeep({ foo_bar: { bar_foo: true } });
pascalcase('fooBar');
pascalcaseKeys({ fooBar: true });
pascalcaseKeysDeep({ fooBar: { barFoo: true } });
Axios Request Interceptors:
const { onRequest, createRequestInterceptor } = require('messaging-api-common');
axios.interceptors.request.use(createRequestInterceptor());
axios.interceptors.request.use(
createRequestInterceptor({
onRequest: (request) => {
console.log(request);
},
})
);