Security News
RubyGems.org Adds New Maintainer Role
RubyGems.org has added a new "maintainer" role that allows for publishing new versions of gems. This new permission type is aimed at improving security for gem owners and the service overall.
@strapi/utils
Advanced tools
Shared utilities for the Strapi packages
@strapi/utils is a utility package for Strapi, a popular open-source headless CMS. This package provides various utility functions that help in developing and managing Strapi applications more efficiently.
sanitizeEntity
The `sanitizeEntity` function is used to remove sensitive information from an entity object based on the model's configuration. This is particularly useful for ensuring that sensitive data like passwords are not exposed in API responses.
const { sanitizeEntity } = require('@strapi/utils');
const entity = { id: 1, name: 'John Doe', password: 'secret' };
const sanitizedEntity = sanitizeEntity(entity, { model: strapi.models.user });
console.log(sanitizedEntity);
parseMultipartData
The `parseMultipartData` function is used to parse multipart form data, which is commonly used for file uploads. This function extracts the data and files from the request context.
const { parseMultipartData } = require('@strapi/utils');
const ctx = { request: { body: {}, files: {} } };
const { data, files } = parseMultipartData(ctx);
console.log(data, files);
contentTypes
The `contentTypes` utility provides functions to work with different content types. For example, `isContentType` checks if a given string is a valid content type.
const { contentTypes } = require('@strapi/utils');
const isContentType = contentTypes.isContentType('application/json');
console.log(isContentType);
Lodash is a modern JavaScript utility library delivering modularity, performance, and extras. It provides a wide range of utility functions for common programming tasks, similar to some of the utilities provided by @strapi/utils, but it is not specific to Strapi.
Validator is a library for string validation and sanitization. While @strapi/utils provides some sanitization functions specific to Strapi models, Validator offers a broader range of validation and sanitization functions for general use.
Formidable is a Node.js module for parsing form data, especially file uploads. It offers similar functionality to the `parseMultipartData` function in @strapi/utils but is more general-purpose and not tied to Strapi.
Shared utilities between Strapi packages.
FAQs
Shared utilities for the Strapi packages
The npm package @strapi/utils receives a total of 175,624 weekly downloads. As such, @strapi/utils popularity was classified as popular.
We found that @strapi/utils demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 7 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
RubyGems.org has added a new "maintainer" role that allows for publishing new versions of gems. This new permission type is aimed at improving security for gem owners and the service overall.
Security News
Node.js will be enforcing stricter semver-major PR policies a month before major releases to enhance stability and ensure reliable release candidates.
Security News
Research
Socket's threat research team has detected five malicious npm packages targeting Roblox developers, deploying malware to steal credentials and personal data.