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 🙏

© 2025 – Pkg Stats / Ryan Hefner

cca-aws-sdk-s3

v0.1.2

Published

s3 module

Readme

cca-aws-sdk-s3

A TypeScript library for managing images in AWS S3 with automatic resizing and optimization.

Features

  • Upload single or multiple images to AWS S3 with automatic resizing
  • Generate signed URLs for stored images
  • Delete images and their associated resources
  • Retrieve paginated lists of stored images
  • Track complete image metadata

Installation

npm install cca-aws-sdk-s3

Usage

Initialization

import { S3ImageStorage, S3Config } from 'cca-aws-sdk-s3';

const imageStorage = new S3ImageStorage({
  region: 'us-east-1',
  bucket: 'my-images-bucket',
  accessKeyId: 'YOUR_AWS_ACCESS_KEY',
  secretAccessKey: 'YOUR_AWS_SECRET_KEY'
});

Basic Operations

// Upload an image
const metadata = await imageStorage.uploadImage(req.file);

// Upload multiple images
const metadataArray = await imageStorage.uploadMultipleImages(req.files);

// Get all image URLs
const urls = await imageStorage.getImageUrls(imageId);

// Get specific size URL
const url = await imageStorage.getImageUrl(imageId, ImageSize.MD);

// Delete an image
await imageStorage.deleteImage(imageId);

// Delete multiple images
await imageStorage.deleteMultipleImages([id1, id2, id3]);

// Get paginated image list
const result = await imageStorage.getImagesList(page, limit);

API Reference

S3ImageStorage

Constructor:

  • constructor(config: S3Config) - Initialize with AWS S3 configuration

Methods:

  • uploadImage(file: Express.Multer.File): Promise<ImageMetadata> - Upload and resize a single image
  • uploadMultipleImages(files: Express.Multer.File[]): Promise<ImageMetadata[]> - Upload multiple images
  • getImageUrl(id: string, size: ImageSize): Promise<string> - Get URL for specific image size
  • getImageUrls(id: string): Promise<Record<ImageSize, string>> - Get URLs for all sizes
  • deleteImage(id: string): Promise<void> - Delete an image and all its sizes
  • deleteMultipleImages(ids: string[]): Promise<void> - Delete multiple images
  • getImagesList(page: number = 1, limit: number = 10): Promise<PaginatedResult<ImageMetadata>> - Get paginated image list

Interfaces

S3Config:

interface S3Config {
  region: string;
  bucket: string;
  accessKeyId: string;
  secretAccessKey: string;
}

ImageMetadata:

interface ImageMetadata {
  id: string;
  originalName: string;
  mimeType: string;
  ORIGINAL_size_kb: number;
  THUMB_size_kb: number;
  SM_size_kb: number;
  MD_size_kb: number;
  LG_size_kb: number;
  XL_size_kb: number;
  createdAt: Date;
  urls: Record<ImageSize, string>;
}

Enums

ImageSize:

enum ImageSize {
  ORIGINAL = "original",
  THUMB = "thumb",
  SM = "sm",
  MD = "md",
  LG = "lg",
  XL = "xl"
}

Example with Express

import express from 'express';
import multer from 'multer';
import { S3ImageStorage } from 'cca-aws-sdk-s3';

const app = express();
const upload = multer({ storage: multer.memoryStorage() });
const imageStorage = new S3ImageStorage({/* config */});

app.post('/upload', upload.single('image'), async (req, res) => {
  try {
    const metadata = await imageStorage.uploadImage(req.file);
    res.status(200).json({ success: true, metadata });
  } catch (error) {
    res.status(400).json({ success: false, error: error.message });
  }
});

app.get('/images', async (req, res) => {
  try {
    const page = parseInt(req.query.page as string) || 1;
    const limit = parseInt(req.query.limit as string) || 10;
    const result = await imageStorage.getImagesList(page, limit);
    res.status(200).json({ success: true, ...result });
  } catch (error) {
    res.status(500).json({ success: false, error: error.message });
  }
});

License

MIT