pink-bears
Version:
Intelligent rate limiting middleware with MongoDB integration and caching for Node.js applications
39 lines (34 loc) • 1.12 kB
JavaScript
const {emitEvent} = require('./errorEmitter');
const {errorConstants} = require('./constants');
const axiosWrapper = require('./AxiosWrapper');
let Axios;
class Iparams {
constructor(accountId, productId, appId, domain, userId) {
this.accountId = accountId;
this.productId = productId;
this.appId = appId;
this.domain = domain;
this.userId = userId;
this.initializeAxiosWrapper();
}
initializeAxiosWrapper = () => {
const AxiosWrapper = new axiosWrapper(this.domain, this.userId);
Axios = AxiosWrapper.getAxiosInstance();
}
get = async (key) => {
try {
const data = {
accountId: this.accountId,
productId: this.productId,
appId: this.appId,
method: 'GET',
key
}
return (await Axios.post(`${this.domain}/api/server/access-iparams`, data))?.data;
} catch (error) {
await emitEvent(errorConstants.iparams, error);
return error;
}
}
}
module.exports = Iparams;