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

devcodes-webhook

v1.0.0

Published

Send Discord and Slack webhooks with a simple, typed API. Built on devcodes-http-tool.

Readme

devcodes-webhook

Send Discord and Slack webhooks with a clean, typed API — no boilerplate, built-in retries, full TypeScript support.

Built on top of devcodes-http-tool.

Install

npm install devcodes-webhook

Quick Start

const { sendWebhook } = require('devcodes-webhook');

await sendWebhook('https://discord.com/api/webhooks/...', {
  content: 'Hello from devcodes-webhook!'
});

Discord

Basic message

const { DiscordWebhook } = require('devcodes-webhook');

const hook = new DiscordWebhook('https://discord.com/api/webhooks/ID/TOKEN');

await hook.sendText('Server is back online ✅');

Send an embed

await hook.sendEmbed({
  title: '🚀 Deployment Complete',
  description: 'Version **1.4.2** is now live.',
  color: 0x57F287, // green
  timestamp: new Date().toISOString(),
  footer: { text: 'Dev Codes CI' },
});

Send multiple embeds

await hook.sendEmbeds([
  { title: 'Service A', description: '✅ Healthy', color: 0x57F287 },
  { title: 'Service B', description: '⚠️ Degraded', color: 0xFEE75C },
  { title: 'Service C', description: '❌ Down',    color: 0xED4245 },
]);

Override webhook name & avatar

await hook.send({
  content: 'Ping!',
  username: 'Alert Bot',
  avatar_url: 'https://example.com/avatar.png',
});

Full embed example

await hook.sendEmbed({
  author: {
    name: 'azaresw',
    url: 'https://github.com/azaresw',
    icon_url: 'https://github.com/azaresw.png',
  },
  title: 'New Pull Request',
  url: 'https://github.com/azaresw/repo/pull/42',
  description: 'Fix memory leak in cache layer',
  color: 0x5865F2,
  fields: [
    { name: 'Branch',   value: '`fix/cache-leak`', inline: true },
    { name: 'Status',   value: 'Open',             inline: true },
    { name: 'Changed',  value: '3 files',          inline: true },
  ],
  thumbnail: { url: 'https://github.com/azaresw.png' },
  footer:    { text: 'GitHub • devcodes-webhook' },
  timestamp: new Date().toISOString(),
});

Slack

Plain text

const { SlackWebhook } = require('devcodes-webhook');

const hook = new SlackWebhook('https://hooks.slack.com/services/...');

await hook.sendText('Deployment finished successfully!');

Block Kit

await hook.sendBlocks([
  {
    type: 'header',
    text: { type: 'plain_text', text: '🚨 Alert' },
  },
  {
    type: 'section',
    text: { type: 'mrkdwn', text: '*Service:* API Gateway\n*Status:* Down' },
  },
]);

Send to a specific channel

await hook.send({
  text: 'Hello #dev!',
  channel: '#dev',
  icon_emoji: ':rocket:',
});

Generic sendWebhook

Works with any service that accepts a JSON webhook body.

const { sendWebhook } = require('devcodes-webhook');

await sendWebhook('https://your-endpoint.com/hook', {
  event: 'user.signup',
  userId: '123',
});

TypeScript

Full type support out of the box.

import { DiscordWebhook, DiscordEmbed, WebhookConfig } from 'devcodes-webhook';

const config: WebhookConfig = { timeout: 5000, retries: 3 };
const hook = new DiscordWebhook('https://discord.com/api/webhooks/...', config);

const embed: DiscordEmbed = {
  title: 'Alert',
  description: 'Something happened.',
  color: 0xED4245,
};

await hook.sendEmbed(embed);

API Reference

new DiscordWebhook(url, config?)

| Method | Signature | Description | |--------|-----------|-------------| | send | (payload: DiscordWebhookPayload) => Promise<WebhookResponse> | Send a raw payload | | sendText | (content: string, extras?) => Promise<WebhookResponse> | Send a plain text message | | sendEmbed | (embed: DiscordEmbed, extras?) => Promise<WebhookResponse> | Send a single embed | | sendEmbeds | (embeds: DiscordEmbed[], extras?) => Promise<WebhookResponse> | Send up to 10 embeds |

new SlackWebhook(url, config?)

| Method | Signature | Description | |--------|-----------|-------------| | send | (payload: SlackWebhookPayload) => Promise<WebhookResponse> | Send a raw payload | | sendText | (text: string, extras?) => Promise<WebhookResponse> | Send a plain text message | | sendBlocks | (blocks: unknown[], extras?) => Promise<WebhookResponse> | Send Block Kit blocks |

sendWebhook(url, payload, config?)

Generic function that POSTs any JSON payload to a URL.

WebhookConfig

| Option | Type | Default | Description | |--------|------|---------|-------------| | timeout | number | 10000 | Request timeout in ms | | retries | number | 2 | Retry attempts on failure | | retryDelay | number | 500 | Delay between retries in ms |

WebhookResponse

interface WebhookResponse {
  ok: boolean;     // true if status 2xx
  status: number;  // HTTP status code
}

Discord bot integration example

const { DiscordWebhook } = require('devcodes-webhook');

const logs = new DiscordWebhook(process.env.LOG_WEBHOOK_URL);

client.on('guildMemberAdd', async (member) => {
  await logs.sendEmbed({
    title: '👋 New Member',
    description: `${member.user.tag} joined **${member.guild.name}**`,
    color: 0x57F287,
    thumbnail: { url: member.user.displayAvatarURL() },
    timestamp: new Date().toISOString(),
    footer: { text: `Members: ${member.guild.memberCount}` },
  });
});

License

MIT © azaresw

Support

Join our Discord for help and updates: discord.gg/ESh2Dp2xX9