pink-bears
Version:
Intelligent rate limiting middleware with MongoDB integration and caching for Node.js applications
38 lines • 991 B
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;