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 🙏

© 2024 – Pkg Stats / Ryan Hefner

ldla-server-uploader-cloudinary

v1.0.5

Published

A Node.js server for uploading, managing, and deleting images with Cloudinary.

Downloads

36

Readme

ldla-server-uploader-cloudinary

Description de l'image

Description

ldla-server-uploader-cloudinary est un composant npm qui permet de mettre en place un serveur Express pour gérer l'upload, la récupération et la suppression d'images via l'API Cloudinary. Ce package est conçu pour être facilement intégré dans un projet Node.js.

Installation

Pour installer le package, exécutez la commande suivante :


- npm install ldla-server-uploader-cloudinary

Utilisation

Prérequis

- Node.js (version 12 ou supérieure)

- Un compte Cloudinary pour gérer les images

Configuration

- Créez un fichier .env à la racine de votre projet pour stocker vos clés API Cloudinary :

CLOUDINARY_CLOUD_NAME=your-cloudinary-cloud-name

CLOUDINARY_API_KEY=your-cloudinary-api-key

CLOUDINARY_API_SECRET=your-cloudinary-api-secret

PORT=3001

- Remplacez your-cloudinary-cloud-name, your-cloudinary-api-key, et your-cloudinary-api-secret par vos informations Cloudinary.

Implémentation

Dans votre fichier principal (par exemple, index.js), importez et utilisez le package :

const { start } = require('ldla-server-uploader-cloudinary');

// Démarre le serveur fourni par le composant //
start({
  port: 3001, // Spécifie le port sur lequel vous voulez démarrer le serveur //
    cloudinary: {
        cloud_name: process.env.CLOUDINARY_CLOUD_NAME,
        api_key: process.env.CLOUDINARY_API_KEY,
        api_secret: process.env.CLOUDINARY_API_SECRET
    },
    corsOptions: {
        origin: '*', // On peut configurer les options CORS ici si nécessaire //
    }
});

// Plus besoin de `app.listen`, car `start` gère le démarrage du serveur //

Routes API disponibles

1. Upload d'images: POST /upload

Description : Cette route permet de télécharger jusqu'à 11 images simultanément sur Cloudinary.

Body de la requête : multipart/form-data avec le champ images contenant les fichiers d'image.

Réponse:

{
  "message": "Upload successful",
  "results": [
    {
      "public_id": "image_id",
      "original_filename": "original_name.jpg",
      "url": "https://res.cloudinary.com/your-cloud-name/image/upload/v1618312789/sample.jpg"
    }
  ]
}

2. Récupérer les images: GET /images

Description : Cette route récupère jusqu'à 150 images stockées sur votre compte Cloudinary.

Réponse :

[
  {
    "public_id": "image_id",
    "url": "https://res.cloudinary.com/your-cloud-name/image/upload/v1618312789/sample.jpg"
  }
]

3. Supprimer une image: DELETE /images/

Description : Cette route permet de supprimer une image spécifique de Cloudinary en utilisant son publicId.

Réponse :

{
  "message": "Image with public ID image_id deleted successfully."
}

Gestion des erreurs
Le serveur renverra un code d'état HTTP 500 et un message d'erreur JSON en cas de problème, comme une erreur d'upload ou de suppression d'image.

Contribution
Les contributions sont les bienvenues ! Si vous souhaitez ajouter des fonctionnalités, corriger des bugs, ou améliorer la documentation, n'hésitez pas à soumettre une pull request.

License
Ce projet est sous licence MIT. Consultez le fichier LICENSE pour plus de détails.