New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More

@strapi/utils

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@strapi/utils

Shared utilities for the Strapi packages

0.0.0-next.7051057497777a23c7418e675330d2fb69c89fec
Version published
Weekly downloads
266K
-0.66%
Maintainers
8
Weekly downloads
 
Created

What is @strapi/utils?

@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.

What are @strapi/utils's main functionalities?

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);

Other packages similar to @strapi/utils

Keywords

FAQs

Package last updated on 29 Jan 2025

Did you know?

Socket

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.

Install

Related posts