1.1.0 • Published 1 year ago

@openstudio/strapi-media-deletion-middleware v1.1.0

Weekly downloads
-
License
MIT
Repository
github
Last release
1 year ago

strapi-media-deletion-middleware

Check if a media is used in any content before deleting it.

Works with strapi 4 and 5

Install

npm i @openstudio/strapi-media-deletion-middleware
# Or
yarn add @openstudio/strapi-media-deletion-middleware

Configuration

Basic

Add in config/middleware.ts

module.exports = ({ env }) => [
  // ...
  {
    resolve: '@openstudio/strapi-media-deletion-middleware',
  },
  // ...
];

Custom

To modify some default values add a config object with the config key you want to edit.

module.exports = ({ env }) => [
  // ...
  {
    resolve: '@openstudio/strapi-media-deletion-middleware',
    config: {
      strapiMajor: 4,
      blackList: [{ relatedType: 'api::article.article', field: 'cover' }],
      whiteList: [
        { relatedType: 'api::article.article', field: 'optionalField' },
      ],
    },
  },
  // ...
];

Config parameters

keydescriptiondefault
strapiMajorStrapi Major version in this project possible values : 4 or 55
blackListSpecify a list of elements whose medias CAN'T be deleted, an empty list means everything is in the black list[]
whiteListSpecify a list of elements whose medias CAN be deleted, for instance if a media is in an optional field you might allow to delete it[]
1.1.0

1 year ago

1.0.0

1 year ago