npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@jsm406/medusa-plugin-carrousel

v1.0.8

Published

Medusa v2 Banner (Hero Slider) plugin with Admin UI and storefront API

Readme

@jsm406/medusa-plugin-carrousel

Plugin de Medusa v2 para gestión de Banners (Hero Slider). Permite administrar slides desde el panel de Medusa Admin y consumirlos desde el storefront en Next.js. Incluye soporte para secciones de "Ofertas".

📦 Instalación como plugin

1. Compilar el plugin

npm run build
# o
npx medusa plugin:build

Esto generará la carpeta .medusa/server con el código compilado.

2. Publicar en npm

npm publish

3. Instalar en una aplicación Medusa

npm install @jsm406/medusa-plugin-carrousel

4. Registrar el plugin en medusa-config.ts

import { defineConfig } from "@medusajs/framework/utils"

export default defineConfig({
  // ... otras configuraciones ...
  plugins: [
    {
      resolve: "@jsm406/medusa-plugin-carrousel",
      options: {},
    },
  ],
})

El módulo banner se registra automáticamente al añadir el plugin en plugins: [] (el loader de Medusa descubre los módulos en .medusa/server/src/modules del paquete). No hace falta añadirlo en modules: [].

🛠️ Estructura del plugin

El plugin incluye:

  • Módulo backend: src/modules/banner/ con modelo Banner (campo category: "banner" | "oferta") y servicio Medusa
  • Workflows: src/workflows/banner/ con createBannerWorkflow, updateBannerWorkflow, deleteBannerWorkflow (con compensación/rollback)
  • API Routes:
    • Rutas protegidas /admin/banners (CRUD completo)
    • Públicas /store/banners (banners activos, category="banner")
    • Públicas /store/ofertas (ofertas activas, category="oferta")
  • Interfaz Admin: Ruta personalizada /app/banners en el panel de Medusa Admin con selector de categoría
  • Componentes: Subida de imágenes vía POST /admin/uploads, tabla con miniatura, estado, acciones editar/eliminar

📂 Estructura de carpetas

src/
├── admin/
│   └── routes/
│       └── banners/
│           └── page.tsx          # Ruta personalizada: /app/banners
├── api/
│   ├── admin/
│   │   ├── banners/
│   │   │   ├── route.ts          # CRUD admin protegido
│   │   └── banners/
│   │       └── [id]/
│   │           └── route.ts      # PUT / DELETE admin con workflow
│   ├── store/
│   │   └── banners/
│   │       └── route.ts          # GET /store/banners (solo activos)
│   └── middlewares.ts            # Validación Zod para body de requests
├── components/
│   └── examples/
│       └── storefront/
│           └── BannerSlider.tsx  # Componente frontend (copy to Next.js app)
├── modules/
│   ├── banner/
│   │   ├── models/
│   │   │   └── banner.ts         # Definición modelo con model.define
│   │   ├── service.ts            # BannerModuleService extends MedusaService
│   │   └── index.ts              # Definición del módulo con BANNER_MODULE
│   └── index.ts                  # Exportaciones del módulo
└── workflows/
    └── banner/
        ├── types.ts                # Tipos compartidos
        ├── steps/
        │   ├── create-banner.ts
        │   ├── update-banner.ts
        │   └── delete-banner.ts
        ├── create-banner-workflow.ts
        ├── update-banner-workflow.ts
        └── delete-banner-workflow.ts
├── lib/
│   └── sdk.ts                    # Instancia Medusa JS SDK (opcional)
package.json
tsconfig.json

🚀 Flujo de trabajo

Workflows incluidos

  1. createBannerWorkflow: Crea un nuevo banner ejecutando el step create-banner-step con compensación que elimina el banner si falla.
  2. updateBannerWorkflow: Actualiza un banner existente; si falla, restaura los valores anteriores.
  3. deleteBannerWorkflow: Elimina un banner; si falla, intenta recrearlo con sus datos originales.

Middlewares Zod

El archivo src/api/middlewares.ts exporta middlewares que validan el cuerpo de las peticiones POST /admin/banners y POST /admin/banners/[id] contra esquemas Zod que exigen title y image_url como campos obligatorios.

📦 Distribución del paquete npm

El paquete publicada en npm incluye solo los archivos compilados en .medusa/server:

  • .medusa/server/workflows/index.js - Workflows exportados
  • .medusa/server/modules/banner/index.js - Definición del módulo Banner
  • .medusa/server/src/admin/ - Extensiones de admin (ruta /app/banners)
  • .medusa/server/api/admin/banners/ - Rutas API administradas

El componente BannerSlider.tsx del storefront no se incluye en el paquete npm (está en examples/storefront/). Los usuarios deben copiarlo a su aplicación Next.js o publicarlo por separado.

🛠️ Desarrollo local

# Compilar y ver cambios en caliente
npm run dev

# O directamente con medusa CLI
npx medusa plugin:develop

Esto iniciará un servidor Medusa con el plugin instalado y verá cambios en tiempo real.

📄 Licencia

MIT# medusa-plugin-carrousel