Security News
tea.xyz Spam Plagues npm and RubyGems Package Registries
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
@soinlabs/request
Advanced tools
Changelog
[1.0.20] - 2024-02-26
Added spread of properties to axios request to support missing properties on previos releases
Readme
This repo/package exports 3 libraries:
Request
: It's a simple and lightweight library based on HTTP Promise queries used as a function, ready to use anywhere.
RequestTracking
: It's a complex library based on HTTP Promise queries used as a Class, it's required to instance and pass a Sequelize object before to use
RequestScheduler
: It's another library used to retrieve fetch the HTTP queries inside in the table WebRequestLogs, it's required to instance and pass a Sequelize object before to use
const { Request } = require('@soinlabs/request')
const response = await Request(params)
- Where
* params - Object
* {string} params.method - Default GET
* {object} params.headers - Default { content-type: application/json }
* {string} params.url - Required
* {string} params.responseType - Default json
* {object} params.data - Default null
* {boolean} params.throwError - Default false
* {array} return response - the data from the URL.
Insert the next SQL script in the database need it:
-- WebRequestLogs definition
CREATE TABLE `WebRequestLogs` (`id` INTEGER PRIMARY KEY AUTOINCREMENT, `data` JSON, `retries` INTEGER, `attempts` INTEGER, `status` INTEGER, `response` JSON, `error` JSON, `method` VARCHAR(255), `url` VARCHAR(255), `createdAt` DATETIME NOT NULL, `updatedAt` DATETIME NOT NULL);
Add the model in package/model or whatever place where is it the Squeeze models/objects
module.exports = (sequelize, DataTypes) => {
const WebRequestLog = sequelize.define(
'WebRequestLog',
{
id: {
allowNull: false,
autoIncrement: true,
primaryKey: true,
type: DataTypes.INTEGER,
},
data: { type: JSON },
retries: { type: DataTypes.INTEGER },
attempts: { type: DataTypes.INTEGER },
status: {
type: DataTypes.INTEGER,
enum: (-1, 0, 1),
},
response: { type: JSON },
error: { type: JSON },
method: { type: DataTypes.STRING },
url: { type: DataTypes.STRING },
},
{
tableName: 'WebRequestLogs',
}
)
return WebRequestLog
}
And finally, the implementation of RequestTracking
const { RequestTracking } = require('@soinlabs/request-tracking')
const { WebRequestLog } = require('models/WebRequestLog')
const request = new RequestTracking(WebRequestLog)
const response = await request.RequestTracking(params)
- Where
* params - Object
* {string} params.method - Default GET
* {object} params.headers - Default { content-type: application/json }
* {string} params.url - Required
* {string} params.responseType - Default json
* {object} params.data - Default null
* {number} params.retries - Default null
* {boolean} params.log - Default null
* {array} return response - the data from the URL.
Implemente RequestScheduler
in cronjobs or scheduler logic
const { RequestScheduler } = require('@soinlabs/ibs/request-scheduler')
const { WebRequestLog } = require('models/WebRequestLog')
const requestScheduler = new RequestScheduler(WebRequestLog)
await requestScheduler.start(limit)
- Where
* {number} limit - Default 10
FAQs
A request package made with retries and traceability
The npm package @soinlabs/request receives a total of 163 weekly downloads. As such, @soinlabs/request popularity was classified as not popular.
We found that @soinlabs/request demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 6 open source maintainers 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
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
Security News
As cyber threats become more autonomous, AI-powered defenses are crucial for businesses to stay ahead of attackers who can exploit software vulnerabilities at scale.
Security News
UnitedHealth Group disclosed that the ransomware attack on Change Healthcare compromised protected health information for millions in the U.S., with estimated costs to the company expected to reach $1 billion.