Skip to content

Instantly share code, notes, and snippets.

View magicspon's full-sized avatar
🤘

Dave Stockley magicspon

🤘
View GitHub Profile
@magicspon
magicspon / create-page.tsx
Last active February 18, 2025 19:38 — forked from Pagebakers/create-page.tsx
Next.js createPage helper with loader pattern
// https://saas-ui.dev/blog/nextjs-create-page-helper-with-loader-pattern
// source: https://gist.github.com/magicspon/c1647cf91909808be0a1eed5448bb56d
// updated by @magicspon
import type { Metadata, ResolvingMetadata } from 'next'
import { unstable_cache as cache } from 'next/cache'
import { draftMode } from 'next/headers'
import type { AnyZodObject, z } from 'zod'
const DEFAULT_REVALIDATE_TIME = 60 * 60 * 24 // 1 DAY
@magicspon
magicspon / sso-login.ts
Last active April 20, 2023 09:19 — forked from jorgemasta/sso-login.ts
SSO Login to BigCommerce using a (Next) API Route
import type { NextApiHandler, NextApiRequest, NextApiResponse } from 'next'
import jwt from 'jsonwebtoken';
import {v4 as uuidv4} from 'uuid';
import concatHeader from '../utils/concat-cookie'
import getConfig from '../utils/get-config'
function getSsoLoginUrl(customerId: number, storeHash: string, storeUrl: string, clientId: string, clientSecret: string) {
const dateCreated = Math.round((new Date()). getTime() / 1000);
const payload = {
"iss": clientId,