Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@strapi/utils

Package Overview
Dependencies
Maintainers
7
Versions
1395
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

  • 4.3.2
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
219K
decreased by-6.63%
Maintainers
7
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 01 Aug 2022

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc