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

zeos-images

v1.0.2

Published

Uma biblioteca para upload e gerenciamento de imagens com suporte a S3/Wasabi

Readme

zeos-images

Uma biblioteca Node.js para upload e gerenciamento de imagens com suporte a S3/Wasabi.

Instalação

npm install zeos-images

Uso Básico

Configuração Standalone

import { ZeosImages } from 'zeos-images';

const imageService = new ZeosImages({
    endpoint: 'https://s3.us-west-1.wasabisys.com',
    bucket: 'meu-bucket',
    accessKey: 'SUA_ACCESS_KEY',
    secretKey: 'SUA_SECRET_KEY',
    region: 'us-west-1', // opcional
    publicUrl: 'https://images.seusite.com', // opcional
    uploadPath: 'uploads', // opcional
    maxFileSize: 5 * 1024 * 1024, // opcional, padrão: 5MB
});

// Upload de arquivo
const result = await imageService.upload({
    buffer: fileBuffer,
    originalname: 'foto.jpg',
    mimetype: 'image/jpeg',
    size: fileBuffer.length
});

if (result.success) {
    console.log('URL da imagem:', result.url);
} else {
    console.error('Erro:', result.error);
}

// Obter arquivo
const file = await imageService.getFile('1234567890-foto.jpg');

// Deletar arquivo
await imageService.deleteFile('1234567890-foto.jpg');

Com Express (Middleware)

import express from 'express';
import { ZeosImages, createUploadRouter } from 'zeos-images';

const app = express();

const imageService = new ZeosImages({
    endpoint: process.env.S3_ENDPOINT,
    bucket: process.env.S3_BUCKET,
    accessKey: process.env.S3_ACCESS_KEY,
    secretKey: process.env.S3_SECRET_KEY,
    publicUrl: 'https://images.seusite.com'
});

// Criar router com rotas pré-configuradas
const uploadRouter = createUploadRouter(imageService, {
    uploadPath: '/upload',      // POST /api/images/upload
    getPath: '/uploads/:filename' // GET /api/images/uploads/:filename
});

app.use('/api/images', uploadRouter);

app.listen(3000, () => {
    console.log('Servidor rodando na porta 3000');
});

Middleware Customizado

import express from 'express';
import { ZeosImages, createUploadMiddleware } from 'zeos-images';

const app = express();

const imageService = new ZeosImages({
    endpoint: process.env.S3_ENDPOINT,
    bucket: process.env.S3_BUCKET,
    accessKey: process.env.S3_ACCESS_KEY,
    secretKey: process.env.S3_SECRET_KEY
});

const upload = createUploadMiddleware({
    maxFileSize: 10 * 1024 * 1024, // 10MB
    blockedExtensions: ['.exe', '.bat', '.sh']
});

app.post('/upload', upload.single('file'), async (req, res) => {
    const result = await imageService.upload(req.file);
    
    if (result.success) {
        res.json({ url: result.url });
    } else {
        res.status(400).json({ error: result.error });
    }
});

API

ZeosImages

Constructor

new ZeosImages(config)

| Parâmetro | Tipo | Obrigatório | Descrição | |-----------|------|-------------|-----------| | endpoint | string | ✅ | URL do endpoint S3/Wasabi | | bucket | string | ✅ | Nome do bucket | | accessKey | string | ✅ | Chave de acesso | | secretKey | string | ✅ | Chave secreta | | region | string | ❌ | Região (padrão: 'us-west-1') | | publicUrl | string | ❌ | URL pública base para os arquivos | | uploadPath | string | ❌ | Prefixo/pasta para uploads (padrão: 'uploads') | | maxFileSize | number | ❌ | Tamanho máximo em bytes (padrão: 5MB) | | blockedExtensions | string[] | ❌ | Extensões bloqueadas |

Métodos

upload(file)

Faz upload de um arquivo.

const result = await imageService.upload({
    buffer: Buffer,
    originalname: string,
    mimetype: string,
    size?: number
});
// Returns: { success: boolean, url?: string, error?: string }
getFile(filename)

Obtém um arquivo do storage.

const result = await imageService.getFile('filename.jpg');
// Returns: { success: boolean, data?: Object, error?: string }
deleteFile(filename)

Deleta um arquivo do storage.

const result = await imageService.deleteFile('filename.jpg');
// Returns: { success: boolean, error?: string }
isExtensionAllowed(filename)

Verifica se a extensão do arquivo é permitida.

const allowed = imageService.isExtensionAllowed('foto.jpg');
// Returns: boolean

createUploadMiddleware(options)

Cria um middleware multer configurado.

const upload = createUploadMiddleware({
    maxFileSize: 5 * 1024 * 1024,
    blockedExtensions: ['.exe']
});

createUploadRouter(zeosImages, options)

Cria um Express Router com rotas de upload pré-configuradas.

const router = createUploadRouter(imageService, {
    uploadPath: '/upload',
    getPath: '/uploads/:filename'
});

Extensões Bloqueadas por Padrão

  • .xll, .exe, .bat, .sh, .cmd, .com, .cpl, .msi
  • .js, .php
  • .svg, .html, .htm, .shtml, .xhtml

Validações

  • Verificação de extensão de arquivo
  • Verificação de tamanho máximo
  • Verificação de conteúdo malicioso em SVGs (scripts, iframes, etc.)

Variáveis de Ambiente Recomendadas

S3_ENDPOINT=https://s3.us-west-1.wasabisys.com
S3_BUCKET=meu-bucket
S3_ACCESS_KEY=sua-access-key
S3_SECRET_KEY=sua-secret-key
S3_REGION=us-west-1

Licença

MIT