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

cca-image-module

v0.0.35

Published

Image module

Readme

cca-image-module

Image management module for Node.js. It provides upload, retrieval, update, and delete operations with AWS S3 storage, pagination, and optional relations.

Installation

npm install cca-image-module

Exports

import { createImageContainer, ImageController, S3Config, s3ConfigManager } from "cca-image-module";

Setup

  1. Configure S3 (must be done before creating the container):
import { s3ConfigManager, S3Config } from "cca-image-module";
import "dotenv/config";

const s3Config: S3Config = {
  accessKeyId: process.env.AWS_ACCESS_KEY_ID!,
  secretAccessKey: process.env.AWS_SECRET_ACCESS_KEY!,
  region: process.env.AWS_REGION!,
  bucket: process.env.AWS_S3_BUCKET!,
};

s3ConfigManager.setConfig(s3Config);

Required env vars:

  • AWS_ACCESS_KEY_ID
  • AWS_SECRET_ACCESS_KEY
  • AWS_REGION
  • AWS_S3_BUCKET

If you want to load config asynchronously, you can set it later and the module will wait for it. Just make sure s3ConfigManager.setConfig(...) is called before createImageContainer(...) runs.

  1. Create container and controller:
import { createImageContainer } from "cca-image-module";
// Use your own BaseDatabase implementation from cca-core
const database = new YourDatabase(/* your connection manager */);
const { imageController } = await createImageContainer(database);
  1. Wire routes (Express + Multer):
import express from "express";
import multer from "multer";

const app = express();
const upload = multer({ dest: "uploads/" });

app.use(express.json());

app.post("/images", upload.single("file"), imageController.createImage);
app.post("/images/bulk", upload.array("files"), imageController.createImages);
app.get("/images/:id", imageController.getImage);
app.get("/images", imageController.getAllImages);
app.get("/images/categories/:id", imageController.getCategoryImages);
app.get("/images/posts/:id", imageController.getPostImages);
app.get("/images/authors/:id", imageController.getAuthorImages);
app.put("/images/:id", imageController.updateImage);
app.delete("/images/:id", imageController.deleteImage);
app.delete("/images", imageController.deleteImages);

app.use((err, req, res, next) => {
  res.status(err?.statusCode ?? 500).json({ error: err?.message ?? "Server error" });
});

API Notes

  • size must be one of: original, thumb, sm, md, lg, xl.
  • For bulk upload:
    • files is an array of files.
    • size can be a single string (applies to all files) or an array matching the files count.
  • Update:
    • size selects which URL field to update.
    • title, description, categoryId, postId can be updated without uploading a new file.

Endpoints Summary

  1. POST /images - create one image (multipart/form-data, file field)
  2. POST /images/bulk - create multiple images (multipart/form-data, files field)
  3. GET /images/:id - get by id
  4. GET /images - paginated list
  5. GET /images/categories/:id - by category
  6. GET /images/posts/:id - by post
  7. GET /images/authors/:id - by author
  8. PUT /images/:id - update
  9. DELETE /images/:id - delete one
  10. DELETE /images - delete many ({ ids: string[] })

License

ISC. See LICENSE.txt.