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

@durbintech/app-webhooks

v0.10.19

Published

Internal API used for Accounts-app mapping for @durbintech Apps

Downloads

57

Readme

Durbin Technologies - App Webhooks

Do yarn add @durbintech/app-webhooks and use!

API Docs

/* It all starts with this import */
import hooks from "@durbintech/app-webhooks";

/* For the API endpoints and Middlewares */
import express from "express";
const app = express();

/* Which kind of database you are planning to use?
 * Currently we support only `typeorm` which in turn can use postgres, sql and even mongodb!
 */
hooks.use("typeorm");

/* There are certain parameters which are required for the proper functioning
 * of the webhooks. You can use `.set(param, value)` for the same
 */

/* This express app will be finally used in turn with the webhooks.
 * The `POST /authenticate` endpoint will be served via this express instance.
 */
hooks.set("express-app", app);

/* You need to set the billable units with which this app will work.
 * These billable units will be required and accounts will read and give proper pricing amount for the same.
 * The names need to unique.
 */
hooks.set("billable-units", [
  { name: "unit-name", description: "What is this unit about?" },
]);

/* When creating an app on the Admin Panel of Accounts, you will get a Client ID and
 * Client Secret. The app needs to know them for proper internal functioning.
 */
hooks.set("client-id", process.env.CLIENT_ID);
hooks.set("client-secret", process.env.CLIENT_SECRET);

/* Optional: Webhook Path. This should match with accounts' knowledge else it won't work.
 * Default is `/webhook`. It can be changed with this set parameter.
 */
hooks.set("webhook-path", "/hookmeup");

/* Bomb has been planted! Fills up Coke on Database and gets ready to serve!
 */
await hooks.arm();

/* Middlewares that app-webhooks provides you
 */

/* `hooks.authenticated()` middleware will set the req.authenticated property on Request.
 * It will now either be `false` or will have the `uuid` of the user using the app
 */
app.use(hooks.authenticated());

/* `hooks.limitOrUse("unit")` will use (by default) 1 unit of the user and will set it in the
 * billing cycle for them. [Pre-requisite: hooks.authenticated() must run before this]
 * If they have reached their limit, it will return a 400 response with "MONTHLY_QUOTA_REACHED" in the body.
 */
app.get("/use-unit", hooks.limitOrUse("unit-name"));

app.get("/custom-path", (req) => {
  if (req.authenticated)
    /* Used up (by default) 1 unit of user from their billing table
     * If they have reached their limit, it will return `false`, else it will use the 1 unit and return `true`
     */
    hooks.addTransaction(req.authenticated, "unit-name");
});

Webhook Paths for Accounts Integration

  1. For inserting/updating max credits of an account
POST /webhook/upsert-credits
Authorization: Bearer <token>

{
    "uuid": "blah-blah-blah",
    "max": [
        { "unit": "understandable-unit", "value": 180 },
        { "unit": "understandable-unit", "value": 200 }
    ]
}
  1. Every Billing Cycle - Get user's usage for Billing
POST /webhook/billing-cycle
Authorization: Bearer <token>

{
    "uuid": "blah-blah-blah"
}

Returns the user's usage before resetting it to 0.

[
  { "unit": "understandable-unit", "value": 180 },
  { "unit": "understandable-unit", "value": 200 }
]
  1. Delete an User - Remove their Permission to use the app
POST /webhook/remove-user
Authorization: Bearer <token>

{
    "uuid": "blah-blah-blah"
}

Returns the user's usage before deleting the records.

[
  { "unit": "understandable-unit", "value": 180 },
  { "unit": "understandable-unit", "value": 200 }
]