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

openhooks

v0.9.18

Published

πŸ”± A server for handling webhook requests.

Downloads

12

Readme

Home Page

πŸ”± A simple server for webhooks.

Build Info npm ndoe version monthly downloads license contributions welcome

Installation

OpenHooks is a command-line-based tool, available at npm registry.

Notice that a Node.js environment is required. The latest version of Node.js is supposed to 8.12 or higher. After installation, set right system variables for Node.js, and there will be two command: node amd npm.

The OpenHook installation command with npm is:

$ npm install openhooks -g

If the privileges of current user is not permitted to install a Node.js module globally (usually as binary commands), add a sudo command before. e.g.

$ sudo npm install openhooks -g

or simply as root user:

# npm install openhooks -g

which is NOT recommended.

After finishing this command, the OpenHooks will be successfully installed on your system. This program provides three commands:

  • openhooks-router
  • openhooks-key
  • openhooks-server

Features

  • RESTFul callbacks
  • Daemonized backend server
  • CRUD hooks routers without restarting server
  • Port customization supported

Quick Start

Manage Webhooks

Use command openhooks-router to manage hooks.

The usage of this command is as below:

Usage: openhooks-router [options] [command]

Options:
  -V, --version             output the version number
  -h, --help                output usage information

Commands:
  generate                  generate route for a webhook
  list                      list all webhooks of the server
  delete <index>            delete a webhook with specified index
  update [options] <index>  update a webhook
  clear                     clear all webhooks

Generate a Webhook

$ openhooks-router generate

This action will start an interactive interface:

? Authentication requirement (false) true
? The command for this webhook (null) cd /workdir/app; git pull; docker-compose up -d --build;
? The description for this webhook (null) rebuild project
There are no keys, generated a new key: 72f4203069cb11e9a734e3dd813b8fd2
Generated a webhook: /hooks/96b2804a215247d383151f59f81ce5cf

NOTICE: If there are no keys in OpenHooks configuration file, openhooks-router generate will generate an access key automatically

List Webhooks

$ openhooks-router list

It will print a table of current webhooks:

Total: 2
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚ (index) β”‚                   path                    β”‚    description    β”‚                          command                           β”‚ auth  β”‚      createTime       β”‚ updateTime β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚    0    β”‚ '/hooks/96b2804a215247d383151f59f81ce5cf' β”‚ 'rebuild project' β”‚ 'cd /workdir/app; git pull; docker-compose up -d --build;' β”‚ true  β”‚ '2019-04-28 23:36:53' β”‚    null    β”‚
β”‚    1    β”‚ '/hooks/5c5069183e884380968e28784c18f66a' β”‚    'ping test'    β”‚                 'ping www.google.com -c 5'                 β”‚ false β”‚ '2019-04-28 23:38:22' β”‚    null    β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

Update a Webhook

Use command update to update a specified webhook. The detailed usage of update is below:

Usage: update [options] <index>

update a webhook

Options:
  -a --auth [boolean]      change the authentication requirement of the webhook
  -c --new-command [cmd]   add command when the webhook is triggered
  -d --desc [description]  add description for the webhook
  -h, --help               output usage information

NOTICE: to change the requirement of authentication, -a option must be specified, e.g. if the authentication of a webhook is supposed to be disabled, the command would be openhooks-router update <index> -a false.

Delete & Clear Webhooks

Use command delete to delete a webhook. The index option is required. delete command will remove the webhook with specified index from list output.

$ openhooks-router delete 0

Use command clear to remove all webhooks.

$ openhooks-router clear

then list will output an empty table:

Total: 0
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚ (index) β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

Manage Keys

Use command openhooks-key to manage access keys.

The usage of this command is as below:

$ openhooks-key -h
Usage: openhooks-key [options] [command]

Options:
  -V, --version   output the version number
  -h, --help      output usage information

Commands:
  generate        generate an access key
  list            list all keys of the server
  delete <index>  delete a key with specified index
  clear           clear all keys

List All Keys

$ openhooks-key list
Total: 1
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚ (index) β”‚                key                 β”‚      createTime       β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚    0    β”‚ '72f4203069cb11e9a734e3dd813b8fd2' β”‚ '2019-04-28 23:36:53' β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

Generate a Key

$ openhooks-key generate

Delete a key

Use command delete to delete an access key. The index option is required. delete command will remove the access key with specified index from list output.

$ openhooks-key delete 0

Clear All Keys

$ openhooks-key clear

Manage Server

Use command openhooks-server. The -a, --action parameter is required and -p, --port parameter is optional.

The action parameter is enumerable, contains start|restart|stop:

Start Server

$ openhooks-server start

The server will listen at *:5000/tcp.

Start the server with port parameter:

$ openhooks-server start 6000

The server will listen at *:6000/tcp

Stop Server

$ openhooks-server stop

Restart Server

$ openhooks-server restart

Trigger a Webhook

A simple HTTP request will trigger a webhook. e.g. The webhook server is listening at localhost:5000, the path of the webhook supposed to be triggered is /hooks/c66ee59c-7a27-47d7-948c-2a5f4d229134, the following command will make it:

$ curl http://localhost:5000/hooks/b11216bc-bc90-4edd-82c3-b588ca7219f5

If it is an authentication-required webhook, the command will be:

$ curl -H "Access-Key:dda3fc50602c11e9a0833dcb0b0dbc38" http://localhost:5000/hooks/b11216bc-bc90-4edd-82c3-b588ca7219f5

Tests

Clone this repository first:

$ git clone https://github.com/lenconda/openhooks.git

Be sure that the NODE_ENV path of system is not set to production, then install dependencies:

$ npm install

Run the test suit by following command:

$ npm run test

Issues

This project still has many things to do since it is a new Node.js module. For any problems and advices, please open a issue at

https://github.com/lenconda/openhooks/issues

Contribution

Thanks for your interest in this project. You are welcomed to make contributions on it. However, before you starting your contribution work, please read the following advice:

  • Read the README first
  • Understand what changes you want to make
  • Look through the issue list and check if there's an issue to solve the same problem
  • Publish or/and redistribute this project should under MIT license

Issues

As said above, before you starting your work, you should check issue list first. The issue list of this project can probably contains known bugs, problems, new demands and future development plans. If you can find an issue or many issues that solves the same problem, it would be great if you can join them to solve the problem.

Fork & Pull Requests

If you decide to write your code in this project, you can fork this project as your own repository, check out to a new branch, from the newest code at master branch. The new branch would be your work bench.

If you want to commit your changes, you are supposed to make an pull request, once you submit the request, the review process will start, if the code meets the requirements, the pull request will pass, and then your code will be in the project. If the request does not be passed, please contact [email protected] or [email protected].

Author(s)

TODOS

  • [ ] Support JSON response customization
  • [x] Better JSON reponse
  • [x] Authorized webhooks
  • [ ] Webhooks notifications
  • [ ] Plugins support

License

MIT