Security News
New Python Packaging Proposal Aims to Solve Phantom Dependency Problem with SBOMs
PEP 770 proposes adding SBOM support to Python packages to improve transparency and catch hidden non-Python dependencies that security tools often miss.
@bluealba/microservices-toolkit
Advanced tools
Little library with a few "common" functionality that we use in our microservices.
npm i @bluealba/microservices-toolkit
Pool is a wrapper on pg-pool that provides the possibility to query centralizing error handling using retries and mapping responses
Pool provides:
Code example
In order to create a connection pool you should use the following code.
const config = ...;
const toolkit = require("@bluealba/microservices-toolkit");
const pgPool = toolkit.buildPGClient(config);
We use the config object to configure the pool expecting the following attributes.
{
host: config.host,
database: config.dbName,
user: config.user,
password: config.password,
port: config.port,
max: config.maxPoolSize,
idleTimeoutMillis: config.idleTimeout,
connectionTimeoutMillis: config.dbTimeout,
maxUses: config.maxUses,
}
Also, the configuration should have the following value to specify the amount of retries
maxQueryRetries
Is a custom error handler for graphql that allows the user to provide errors with extensions that
Configure the custom error handling using:
const toolkit = require("@bluealba/microservices-toolkit");
const graphqlCustomErrorFn = toolkit.graphqlCustomErrorFn;
app.use(
"/graphql",
graphqlHTTP({
schema,
pretty: true,
graphiql: true,
customFormatErrorFn: graphqlCustomErrorFn(),
})
);
Errors should be created adding an extension field like in this example:
class StatusCodeError extends Error {
constructor(statusCode, errorCode, message) {
super(message);
this.extensions = { errorCode: errorCode, statusCode: statusCode, message: message };
}
}
Simple error handler for express that catches any loose error and turns it into a well-formed JSON error with a 500 status code.
const toolkit = require("@bluealba/microservices-toolkit");
const errorHandler = toolkit.errorHandler;
app.use(errorHandler(logger));
Filter that adds an auth object to the request using the x-forwarded-user-* headers added by the proxy this object provides:
Code example
const toolkit = require("@bluealba/microservices-toolkit");
const gatewayAuth = toolkit.gatewayAuth;
app.use(gatewayAuth());
const toolkit = require("@bluealba/microservices-toolkit");
const getAuthHeaders = toolkit.getAuthHeaders;
const authHeaders = getAuthHeaders(req);
wraps any give call with a method that logs the time the method takes to run when called
const toolkit = require("@bluealba/microservices-toolkit");
const run = toolkit.run;
module.exports = run(getSegments, "getSegments");
Util class that provides methods to generate sql parts.
Code example
const toolkit = require("@bluealba/microservices-toolkit");
const { generateAnyClause } = toolkit.sqlUtils;
FAQs
Library that contains common elements used in microservices
The npm package @bluealba/microservices-toolkit receives a total of 3 weekly downloads. As such, @bluealba/microservices-toolkit popularity was classified as not popular.
We found that @bluealba/microservices-toolkit demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 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
PEP 770 proposes adding SBOM support to Python packages to improve transparency and catch hidden non-Python dependencies that security tools often miss.
Security News
Socket CEO Feross Aboukhadijeh discusses open source security challenges, including zero-day attacks and supply chain risks, on the Cyber Security Council podcast.
Security News
Research
Socket researchers uncover how threat actors weaponize Out-of-Band Application Security Testing (OAST) techniques across the npm, PyPI, and RubyGems ecosystems to exfiltrate sensitive data.