shopify-validate

1.0.0 • Public • Published

shopify-validate

Simple express middleware to validate shopify web hooks

Install

$ npm install --save shopify-validate

Usage

var express = require('express')
  , bodyParser = require('body-parser')
  , Shopify = require('shopify-validate')
  , shopifySecret = process.env.SHOPIFY_SECRET
 
var shopify = new Shopify(shopifySecret)
// make sure the shopify validate middleware
// is added before bodyParser
var middleware = [shopify, bodyParser.json()]
 
var app = express()
 
app.post('/webhook', middleware, function(req, res) {
  // validate the request is from shopify
  if (!req.fromShopify()) {
    return res.status(401).send()
  }
 
  // send success notification to shopify
  // done before to prevent timeout
  res.status(200).send()
 
  var body = req.body
  // process webhook
})

Test

$ npm test

License

MIT (See LICENSE for more info)

Author

Evan Lucas

(c) 2014 GAW Miners

Package Sidebar

Install

npm i shopify-validate

Weekly Downloads

26

Version

1.0.0

License

MIT

Last publish

Collaborators

  • eh
  • evanlucas