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

@strapi/utils

Package Overview
Dependencies
Maintainers
8
Versions
1614
Alerts
File Explorer

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.37494b34d1b30bf22cf798b24fa74ec1b1b35f20
Source
npm
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

strapi

FAQs

Package last updated on 19 Feb 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