@lcap/nasl
Version:
NetEase Application Specific Language
59 lines • 1.5 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
const rp = require('axios');
// const logger = require('@utils/logger');
const timeout = 600000;
module.exports = class BaseService {
get(url, params) {
return rp(url, { params })
.then((res) => res.data);
}
post(opts) {
const options = {
method: 'POST',
json: true,
timeout,
...opts,
};
return rp(options)
.then((res) => {
return res || false;
}).catch((e) => {
if (!(e.req && e.req.path && e.req.path.includes('/callback'))) {
// logger.error('post error:', e);
}
throw e;
});
}
put(opts) {
const options = {
method: 'PUT',
json: true,
timeout,
...opts,
};
return rp(options)
.then((res) => {
return res || false;
}).catch((e) => {
// logger.error('put error:', e);
throw e;
});
}
delete(opts) {
const options = {
method: 'DELETE',
json: true,
timeout,
...opts,
};
return rp(options)
.then((res) => {
return res || false;
}).catch((e) => {
// logger.error('delete error:', e);
throw e;
});
}
};
//# sourceMappingURL=BaseService.js.map