Neatly Punctuated Musings
Share your code. npm Orgs help your team discover, share, and reuse code. Create a free org »

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

install

npm i shopify-validate

Downloadsweekly downloads

2

version

1.0.0

license

MIT

homepage

github.com

repository

Gitgithub

last publish

collaborators

  • avatar
  • avatar