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 🙏

© 2024 – Pkg Stats / Ryan Hefner

codyfight-webhook

v1.0.10

Published

Codyfight webhook utility

Downloads

18

Readme

codyfight-webhook

Codyfight webhook utility for sending deployment notifications to Discord or any other webhook service.

Installation

yarn add codyfight-webhook

or

npm install codyfight-webhook

Usage - Discord Webhook

discordWebhook.js

This file contains utility functions for sending Discord webhook messages.

Functions

  • sendDiscordMessage(webhookUrl: string, messageType: string, pipelineUrl: string): Promise<void>

    • Sends a Discord webhook message with the specified webhook URL and message type.
    • Parameters:
      • webhookUrl: The URL of the Discord webhook.
      • messageType: The type of message to send (success or failure).
      • pipelineUrl: The URL of the pipeline.
    • Returns: Promise<void>

discord.js

This file is the main interface for sending Discord webhook messages using the discordWebhook.js utility functions.

It Provides a command-line interface for sending Discord webhook messages.

Command-line Usage

node discord.js -u <webhookUrl> -p <pipelineUrl> -t <messageType>

Options

  • -u, --url <webhookUrl>: Specifies the URL of the Discord webhook. (Required)
  • -p, --pipeline <pipelineUrl>: Specifies the URL of the pipeline. (Required)
  • -t, --type <messageType>: Specifies the type of message to send (success or failure). Default is success. (Optional)

Examples

  1. Send a success message to a Discord webhook:

    node discord.js -u <webhookUrl> -p <pipelineUrl>
  2. Send a failure message to a Discord webhook:

    node discord.js -u <webhookUrl> -p <pipelineUrl> -t failure

AWS CodeBuild Integration

Important: If you are using AWS CodeBuild, you can use the following node.js script to wrap the discord.js script and send Discord webhook notifications after each CodeBuild run.

send_discord_notification.js

const { runDiscordNotification } = require("codyfight-webhook");
runDiscordNotification();

Make sure the environment variables BRANCH_NAME, WEBHOOK_DISCORD_URL and WEBHOOK_PIPELINE_URL are set in your CodeBuild project.

buildspec.yml

To integrate the Discord webhook notification into your AWS CodeBuild pipeline, add the following commands to the post_build phase of your buildspec.yml file:

version: 0.2

env:
  variables:
    BRANCH_NAME: '#{SourceVariables.BranchName}'

  parameter-store:
    WEBHOOK_DISCORD_URL: '/CodeBuild/codyfight-web-prod/WEBHOOK_DISCORD_URL'
    WEBHOOK_PIPELINE_URL: '/CodeBuild/codyfight-web-prod/WEBHOOK_PIPELINE_URL'
    # ... other environment variables

phases:
  # ... other phases

  post_build:
    on-failure: ABORT
    commands:
      - node send_discord_notification.js

Make sure to replace send_discord_notification.js with the filename of your script.

With these instructions, your Discord webhook notification will be sent after each CodeBuild run, indicating whether the build was successful or failed.