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 🙏

© 2024 – Pkg Stats / Ryan Hefner

@cloak-app/shopify

v2.1.0

Published

Shopify Storefront API client and related helpers.

Downloads

13

Readme

@cloak-app/shopify

Shopify Storefront API client and related helpers.

Install

  1. Install with yarn add @cloak-app/shopify
  2. Add to nuxt.config with buildModules: ['@cloak-app/shopify']

Module Options

Set these properties within cloak: { shopify: { ... } } in the nuxt.config.js:

  • url - Your public Shopify store URL, for example: https://brand.myshopify.com or https://shop.brand.com. Defaults to process.env.SHOPIFY_URL.
  • storefront:
    • token - The Storefront API token of your custom app. Defaults to process.env.SHOPIFY_STOREFRONT_TOKEN.
    • language - A Storefront API recognized LanguageCode. Defaults to the 1st part of process.env.CMS_SITE if it is ISO-like (ex: if en_US or en-US then EN).
    • country - A Storefront API recognized CountryCode. Defaults to the 2nd part of process.env.CMS_SITE if it is ISO-like (ex: if en_US or en-US then US).
    • injectClient - Boolean for whether to inject the $storefront client globally. Defaults to true. You would set this to false when this module is a depedency of another module (like @cloak-app/algolia) that is creating $storefront a different way.
  • mocks - An array of objects for use with mockAxiosGql.

Usage

Inside of Nuxt app

The storefront Nuxt plugin injects $storefront globally. This is an Axios instance with it's baseUrl set to cloak.shopify.endpoint. In addition, you can call:

  • $storefront.execute({ query, variables }) - Executes a GraphQL request that automatically adds a site GraphQL variable with the value from the cloak.craft.site value.

Inside of Nuxt module

You can use the makeModuleStorefrontClient() factory method within a Nuxt module to build a $storefront instance. In a module, we can't use the instance that is injected by the storefront-client plugin because that is constructed later in the lifecycle.

// A Nuxt module
import { makeModuleStorefrontClient } from '@cloak-app/shopify/factories'
export default function() {
  const $storefront = makeModuleStorefrontClient(this)
}

Outside of Nuxt

You can make an instance of the Storefront Axios client when outside of Nuxt (like in a Shopify JS entry point) as follows:

import { makeStorefrontClient } from '@cloak-app/shopify/factories'
import mergeClientHelpers from '@cloak-app/shopify/factories/merge-helpers'
const storefront = mergeClientHelpers(makeStorefrontClient({
  url: process.env.SHOPIFY_URL,
  token: process.env.SHOPIFY_STOREFRONT_TOKEN,
}))

// Optional, inject it globally into Vue components
import Vue from 'vue'
Vue.prototype.$storefront = storefront

Contributing

Run yarn dev to open a Nuxt dev build of the demo directory.