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

wundertec-core

v1.0.0

Published

Librería estándar de utilidades e integraciones AWS + helpers generales

Readme

wundertec-core

Librería estándar de utilidades e integraciones AWS + helpers generales en TypeScript


💡 Características

  • AWS SDK v3: S3, SES y SNS con funciones para operaciones comunes y URLs firmados.
  • Fechas y zonas horarias: moment-timezone con zona por defecto CDMX y opción de cambiar.
  • Temporizadores: sleep y withTimeout para control de flujos asíncronos.
  • Colecciones: chunk, flatten, uniq, groupBy.
  • Reintentos: retry con exponentialBackoff configurable.
  • HTTP: AxiosClient con métodos get, post, put, delete.
  • Configuración: loadEnv, getConfig para manejo de .env y variables.
  • Logging: Logger con niveles info, warn, error, debug.

🚀 Instalación

npm install wundertec-core
# o con yarn
yarn add wundertec-core

⚙️ Configuración de entorno

Si usas un archivo .env, al inicio de tu aplicación (por ejemplo en src/index.ts):

import { loadEnv } from "wundertec-core";
loadEnv(); // carga variables desde .env

| Variable | Descripción | | ----------------------- | ------------------------------------------------------ | | DEFAULT_TIMEZONE | Zona horaria por defecto (e.g. America/Mexico_City). | | AWS_REGION | Región AWS (p.ej. us-east-1). | | AWS_ACCESS_KEY_ID | ID de acceso AWS (si no usas roles). | | AWS_SECRET_ACCESS_KEY | Clave secreta AWS. | | SES_FROM_ADDRESS | Direccion “From” por defecto para SES. | | DEBUG | Activa logs debug ("true" o "false"). |

Si faltan variables, la librería usará defaults o fallará con error claro.


📦 Uso detallado

Importa todo desde el entrypoint:

import {
  /* AWS S3 */
  uploadObject,
  getObject,
  deleteObject,
  getSignedGetUrl,
  getSignedPutUrl,
  /* AWS SES */
  sendEmail,
  sendRawEmail,
  /* AWS SNS */
  sendSMS,
  publishTopic,
  /* Fechas */
  now,
  format,
  diff,
  add,
  subtract,
  /* Temporizadores */
  sleep,
  withTimeout,
  /* Colecciones */
  chunk,
  flatten,
  uniq,
  groupBy,
  /* Reintentos */
  retry,
  exponentialBackoff,
  /* HTTP */
  AxiosClient,
  /* Configuración */
  getConfig,
  /* Logging */
  Logger,
} from "wundertec-core";

☁️ AWS S3

// Subir archivo
await uploadObject("mi-bucket", "path/archivo.txt", Buffer.from("Hola"));

// Obtener contenido
const data: Buffer = await getObject("mi-bucket", "path/archivo.txt");

// Eliminar objeto
await deleteObject("mi-bucket", "path/archivo.txt");

// URL firmado GET
const urlGet = await getSignedGetUrl("mi-bucket", "path/privado.jpg", 600);

// URL firmado PUT
const urlPut = await getSignedPutUrl("mi-bucket", "path/subida.bin", 600);

✉️ AWS SES

// Enviar email HTML
await sendEmail(
  ["[email protected]"],
  "Asunto de prueba",
  "<h1>Hola</h1><p>Este es un email</p>"
);

// Envío raw (p.ej con attachments)
await sendRawEmail({ RawMessage: { Data: rawBuffer } });

📲 AWS SNS / SMS

// Enviar SMS directo
await sendSMS("+5215550000000", "Mensaje de prueba");

// Publicar en tópico SNS
await publishTopic(
  "arn:aws:sns:us-east-1:123456789012:mi-topic",
  "Notificación importante"
);

📆 Fecha y hora (moment-timezone)

// Momento actual en CDMX
console.log(now().format());

// Formato específico y zona ET
console.log(format(new Date(), "YYYY-MM-DD HH:mm", "America/New_York"));

// Diferencia en días
console.log(diff("2025-05-01", "2025-04-24", "days"));

// Sumar 3 horas
const plus3 = add("2025-04-24T12:00:00Z", 3, "hours");

// Restar 30 minutos\console.log(subtract(plus3, 30, 'minutes').format());

⏱️ Temporizadores

// Pausar 2s
await sleep(2000);

// Timeout en promesa
await withTimeout(fetchData(), 5000, new Error("Tiempo excedido"));

🔢 Colecciones

// Chunk de 5 en 2
console.log(chunk([1, 2, 3, 4, 5], 2)); // [[1,2],[3,4],[5]]

// Aplanar
console.log(flatten([[1], [2, 3], []])); // [1,2,3]

// Únicos
console.log(uniq([1, 2, 2, 3, 3, 3])); // [1,2,3]

// Agrupar por clave
type Item = { type: string; value: number };
const items: Item[] = [
  { type: "A", value: 1 },
  { type: "B", value: 2 },
  { type: "A", value: 3 },
];
console.log(groupBy(items, (x) => x.type));
// => { A: [{...},{...}], B: [...] }

🔄 Reintentos y Backoff

// Backoff exponencial
console.log(exponentialBackoff(0)); // 100
console.log(exponentialBackoff(1)); // 200

// Retry automático
const result = await retry(() => fetchUnstable(), {
  retries: 5,
  baseDelay: 200,
  maxDelay: 5000,
});

🌐 HTTP con Axios

const api = new AxiosClient({
  baseURL: "https://api.miservicio.com",
  timeout: 8000,
});

// GET JSON
const users = await api.get<User[]>("/users");

// POST datos y recibir respuest
const newUser = await api.post<User>("/users", { name: "Juan" });

// PUT y DELETE similares
await api.put("/items/1", { qty: 10 });
await api.delete("/items/2");

⚙️ Configuración y Variables

// Leer var con fallback
const port = getConfig("PORT", "3000");
console.log(`App corriendo en puerto ${port}`);

📝 Logging

const log = new Logger("MiApp");
log.info("Inicio de aplicación");
log.warn("Esto es una advertencia");
log.error("Ha ocurrido un error");
log.debug("Valor X:", x); // solo si DEBUG=true

🧪 Tests

npm test   # Jest con coverage

🔁 CI/CD & Publicación

  • Lint: npm run lint
  • Build: npm run build
  • Test: npm test
  • Release: npm run release (publicación automática en NPM al mergear en main)

Revisa Jenkinsfile para pipeline de ejemplo.


🤝 Contribuciones

¡Bienvenidos PRs y issues! Sigue las guías de estilo y testing.


📄 Licencia

MIT © Hypernetics