1.0.5 • Published 4 years ago

verify-shopify-webhook v1.0.5

Weekly downloads
39
License
MIT
Repository
github
Last release
4 years ago

verify-shopify-webhook

Verify shopify webhook using any API solution, make your own middleware easily. Requires a raw body (shopify requirement), but parses to JSON for you. Only dependency is on raw-body, this is a very tiny library.

Installation

npm i verify-shopify-webhook

Usage

import verifyWebhook from 'verify-shopify-webhook';

const middleware = async (req, res, next) => {
    const shopifySecret = process.env.SHOPIFY_SECRET;

    const { verified, topic, domain, body } = await verifyWebhook(
        req,
        shopifySecret
    );

    if (!verified) {
        return res.status(403).send();
    }

    req.body = body;

    return next();
};