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

shoplazza-app-express

v0.2.4

Published

Express helpers for building Shoplazza apps with OAuth and Admin API support.

Readme

shoplazza-app-express

shoplazza-app-express is an Express integration layer for Shoplazza apps.

It is modeled after @shopify/shopify-app-express, but uses:

The package gives you a shoplazzaApp() factory with:

  • OAuth install and callback middleware
  • Session storage abstraction with an in-memory default
  • Authenticated-session middleware for protected routes
  • Embedded-app friendly redirect helpers
  • A typed helper to build Shoplazza Admin API clients from the active session

Install

npm install shoplazza-app-express

If you want to use Redis-backed session storage, also install:

npm install redis

Quick start

import express from "express";
import { shoplazzaApp } from "shoplazza-app-express";

const app = express();

const shoplazza = shoplazzaApp({
  api: {
    clientId: process.env.SHOPLAZZA_CLIENT_ID!,
    clientSecret: process.env.SHOPLAZZA_CLIENT_SECRET!,
    scopes: ["read_shop", "read_products"],
    appUrl: "https://your-app.example.com",
    apiVersion: "2025-06",
    isEmbeddedApp: true
  },
  auth: {
    path: "/api/auth",
    callbackPath: "/api/auth/callback"
  },
  hooks: {
    async afterAuth({ session, admin }) {
      console.log(`OAuth completed for ${session.shop}`);

      // Run one-time setup work here, for example:
      // await registerWebhooks(session);
      // await admin.getShop();
    }
  },
  webhooks: {
    path: "/api/webhooks"
  }
});

app.get(shoplazza.config.auth.path, shoplazza.auth.begin());
app.get(
  shoplazza.config.auth.callbackPath,
  shoplazza.auth.callback(),
  shoplazza.redirectToShoplazzaOrAppRoot()
);
app.post(
  shoplazza.config.webhooks!.path,
  shoplazza.processWebhooks({
    webhookHandlers: {
      "app/uninstalled": async ({ shop }) => {
        console.log(`App uninstalled from ${shop}`);
      }
    }
  })
);

app.use("/api/*", shoplazza.validateAuthenticatedSession());

app.get("/api/shop", async (_req, res) => {
  const shop = await res.locals.shoplazza.admin.getShop();
  res.json(shop.data);
});

app.get("/", shoplazza.ensureInstalledOnShop(), (_req, res) => {
  res.send("App is installed");
});

app.listen(3000);

Redis session storage

import express from "express";
import { createClient } from "redis";
import { RedisOAuthStateStorage, RedisSessionStorage, shoplazzaApp } from "shoplazza-app-express";

const redis = createClient({
  url: process.env.REDIS_URL
});

await redis.connect();

const app = express();
const shoplazza = shoplazzaApp({
  api: {
    clientId: process.env.SHOPLAZZA_CLIENT_ID!,
    clientSecret: process.env.SHOPLAZZA_CLIENT_SECRET!,
    scopes: ["read_shop"],
    appUrl: "https://your-app.example.com"
  },
  auth: {
    path: "/api/auth",
    callbackPath: "/api/auth/callback"
  },
  sessionStorage: new RedisSessionStorage({
    client: redis,
    prefix: "shoplazza:session",
    ttlSeconds: 60 * 60 * 24 * 30
  }),
  oauthStateStorage: new RedisOAuthStateStorage({
    client: redis,
    prefix: "shoplazza:oauth-state"
  })
});

Notes

  • Default session storage is memory-only and is not suitable for multi-instance production deployments.
  • OAuth state storage also defaults to in-memory. For embedded or App Store installs, prefer a shared store such as RedisOAuthStateStorage so callback validation does not depend on third-party cookies or a single app instance.
  • RedisSessionStorage implements the same storage contract as MemorySessionStorage, but persists sessions in Redis instead of process memory.
  • The package intentionally mirrors the flow of @shopify/shopify-app-express, but it does not attempt to emulate Shopify-only features such as App Bridge reauthorization headers.
  • Start installations from your app's auth route such as /api/auth?shop=demo-shop.myshoplaza.com, not from a prebuilt Shoplazza /admin/oauth/authorize or plugin authorization URL. This package stores the OAuth state in a signed cookie before redirecting to Shoplazza, so skipping the app route will cause Invalid OAuth state on the callback.
  • hooks.afterAuth runs after a successful OAuth callback and before the default redirect middleware. If it sends a response, the default redirect is skipped.
  • Embedded apps served over HTTPS default to SameSite=None; Secure cookies so the OAuth state survives the iframe-to-top-window redirect. The library also keeps a short-lived server-side copy of the OAuth state and uses it as a fallback when the browser does not return the OAuth cookie. For local HTTP development, use an HTTPS tunnel or override cookieOptions carefully.
  • For embedded redirects, the package falls back to top-window redirects unless you provide a custom embeddedAppUrl builder.
  • Webhook signature verification expects the raw request body. Mount webhook routes before JSON body parsing, or use express.raw({ type: "*/*" }).