0.1.1 • Published 2 years ago

solid-webhook-client v0.1.1

Weekly downloads
-
License
MIT
Repository
github
Last release
2 years ago

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 });
});
0.1.0

2 years ago

0.1.1

2 years ago

0.0.0

2 years ago