solid-webhook-client
TypeScript icon, indicating that this package has built-in type declarations

0.1.1 • Public • Published

Solid Webhook Client

Installation

npm i solid-webhook-client

Usage

import { subscribe, unsubscribe, parseIncomingRequest } from "solid-webhook-client";
import { fetch } from "@inrupt/solid-client-authn-js";
import express from "express";
import bodyParser from "body-parser";

const app = express();

app.post("/webhook", bodyParser.json({ type: "application/ld+json" }), async (req, res) => {
  console.log("Webhook request");
  if (await verifyAuthIssuer(req.headers.authorization) === "https://example.pod") {
    console.log("Webhook valid");
    console.log(JSON.parse(req.body));
  } else {
    console.log("This issuer is invalid");
  }

  res.sendStatus(200);
});

app.listen(3000, () => {
  // Create the webhook subscription
  subscribe("https://example.pod/resource1", { fetch: fetch });
});

Readme

Keywords

none

Package Sidebar

Install

npm i solid-webhook-client

Weekly Downloads

40

Version

0.1.1

License

MIT

Unpacked Size

75.3 MB

Total Files

2864

Last publish

Collaborators

  • jaxoncreed