npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

shopiful

v0.0.5

Published

Sever-side middleware, generating API endpoints to access Shopify products decorated with extra Contentful entry data

Readme

Shopiful

Sever-side middleware, generating API endpoints to access Shopify products decorated with extra Contentful entry data.

npm GitHub GitHub issues

Utilising the Shopify Storefront API, the middleware fetches collections or products from Shopify then intrinsically fetches related the relative entry from Contentful.

Why? 🧐 Because whilst Shopify is great for most ecommerce features, it isn't geared for adding rich page content. So this module helps solve that 👍🏼

Getting Started

This module is best used with SSR or statically generated builds. It is recommended that the exposed endpoints are used to hydrate your app with data ideally into the Vuex store via the nuxtServerInit action. For more information on this, check the examples section.

Prerequisites

Firstly, it is assumed you already have a Shopify store. If not, head over to Shopify to get going. Secondly, you'll need a Contentful account and space setup. Again, if you haven't then head to Contentful to set this up.

Setup

Add Shopiful dependency to your project

Using Yarn:

$ yarn add shopiful

Using NPM:

$ npm install shopiful

Add the module to your nuxt.config.js file

export default {
  modules: [
    'shopiful'
  ]
}

Configuration variables

Now you'll need to grab the following configuration keys:

Shopify

  • Store domain (e.g your-shop-name.myshopify.com)
  • Access token

Contentful

  • Space ID
  • Access token

It is recommended that these keys are stored in an .env file and made available to the middleware via the @nuxtjs/dotenv package. Store the keys like so:

shopify_access_token=xxx
shopify_domain=xxx
contentful_space_id=xxx
contentful_access_token=xxx

It is likely you'll be using the Shopify SDK on the client side for processing carts and checkouts so storing the keys here will make it handy for that too.

Options

⚠️ Currently, options are not available. They will be available in upcoming releases.

Proposed options

  • Cache - Boolean - Cache SSR request feature
  • API Path - String - Add custom API path (default /api/{products|collections})

Contentful setup

Now we have the module setup, we need to configure the content model in Contentful so data entities link correctly to products. Use the following steps:

  • Head over to your admin panel of Contentful
  • Navigate to your space and go to "Content Model"
  • Click "Add Content Type" and give it the name "Product"
  • Now navigate to the new content type and add a field
  • Add a text field. Call it "ID". The Field ID will automatically generate as "id". This also should be a short text field
  • Click "Create and configure"
  • Navigate to "Validations" and check "Required field" and "Unique field"
  • Now navigation to "Apperance" and select "slug"

Now you can add as many or as little fields to this entry type to help decorate your products.

Linking a Shopify product with Contentful entry

To link a Contentful product entry to a Shopify product, you'll need to add the Shopify product ID to the entry you create in the ID field. This will now link the entry with the Shopify product.

Screenshot 2020-02-27 at 23 06 44

Examples

We recommend using axios for your applications HTTP requests. Nuxt have a module for this. If you don't like axios then by all means use whatever method you want.

In asyncData

// pages/products/_slug.vue

export default {
  asyncData({ app, params, error }) {
    return app.$axios
      .get(`api/products/${params.slug}`)
      .then((res) => {
        return { product: res.data }
      })
      .catch((err) => {
        return error({ statusCode: 404, message: err.message })
      })
  }
}

Hydrating store with nuxtServerInit

// store/index.js

export const actions = {
  nuxtServerInit({ commit, dispatch }, { app }) {
    const collectionsRequest = app
      .$axios('/api/collections')
      .then((collections) => {
        commit('products/setCollections', collections.data)
      })
    const productsRequest = app.$axios('/api/products').then((products) => {
      commit('products/setProducts', products.data)
    })
    return Promise.all([collectionsRequest, productsRequest])
  }
}

Built With

Roadmap

  • 🔥Add options functionality
  • 🔥Improve defencive code fallbacks
  • 🔷Add tests
  • 🔻Convert to typescript
  • 🔻Add collections decorating

Contributing

Please read CONTRIBUTING.md for details on our code of conduct, and the process for submitting pull requests to us.

Versioning

We use SemVer for versioning. For the versions available, see the tags on this repository.

Authors

See also the list of contributors who participated in this project.

License

This project is licensed under the MIT License - see the LICENSE.md file for details

Acknowledgments

  • Shopify
  • Contentful