Here is a simple plugin with no config and it runs on a single lifecycle event postBuild
// Plugin code |
exports.handler = async (event, context) => { | |
const shop = event.queryStringParameters.shop | |
const redirectUri = event.queryStringParameters.redirect | |
const apiKey = process.env.SHOPIFY_API_KEY | |
const scopes="read_content,write_content,read_products,read_themes,write_themes" | |
if (shop) { | |
const installUrl = 'https://' + shop + | |
'/admin/oauth/authorize?client_id=' + apiKey + | |
'&scope=' + scopes + |
const crypto = require("crypto") | |
const querystring = require("querystring") | |
const fetch = require("isomorphic-fetch") | |
const Account = require("./models/account") | |
exports.handler = async (event, context) => { | |
const { shop, hmac, code, timestamp } = event.queryStringParameters | |
const apiKey = process.env.SHOPIFY_API_KEY | |
const apiSecret = process.env.SHOPIFY_API_SECRET |
const Account = require("../models/account") | |
module.exports = (handler) => async (event, context) => { | |
let auth = event.headers.authorization | |
auth = auth.replace(/^Basic\s/, "") | |
auth = Buffer.from(auth, 'base64').toString() | |
const [id, token] = auth.split(":") | |
const account = await Account.get({ id }) |
function (user, context, callback) { | |
if (context.clientMetadata && context.clientMetadata.shopify_domain && context.clientMetadata.shopify_multipass_secret) | |
{ | |
const RULE_NAME = 'shopify-multipasstoken'; | |
const CLIENTNAME = context.clientName; | |
console.log(`${RULE_NAME} started by ${CLIENTNAME}`); | |
const now = (new Date()).toISOString(); | |
let shopifyToken = { | |
email: user.email, |
import React, { useState, useEffect } from 'react' | |
import { useDebounce } from './use-debounce' | |
const MySearchComponent = props => { | |
const [search, setSearch, { | |
signal, | |
debouncing | |
}] = useDebounce('') | |
const [results, setResults] = useState([]) |
// Custom promise-based compose | |
const composeWithPromise = (...args) => | |
R.composeWith((f, val) => { | |
if (val && val.then) { | |
return val.then(f); | |
} | |
if (Array.isArray(val) && val.length && val[0] && val[0].then) { | |
return Promise.all(val).then(f); | |
} | |
return f(val); |
import {useEffect} from 'react' | |
import {RecoilRoot, useRecoilState, atom} from 'recoil' | |
// User data | |
const user1 = {username: 'joe', bio: "You will never see me, unless of course this example is totally broken."} | |
const user2 = {username: 'bob', bio: "I am the one true user."} | |
const user3 = {username: 'fred', bio: "Just kidding, make way for the new guy."} | |
// Recoil atom to store user. The default user is user1, but it will be |
// original code: https://github.com/AnthumChris/fetch-progress-indicators | |
const element = document.getElementById('progress'); | |
fetch('url') | |
.then(response => { | |
if (!response.ok) { | |
throw Error(response.status+' '+response.statusText) | |
} |
The package that linked you here is now pure ESM. It cannot be require()
'd from CommonJS.
This means you have the following choices:
import foo from 'foo'
instead of const foo = require('foo')
to import the package. You also need to put "type": "module"
in your package.json and more. Follow the below guide.await import(…)
from CommonJS instead of require(…)
.