@gurulu/node
v1.0.3
Published
Gurulu server SDK. Outcome verification (purchase_completed, signup_completed). Express/Fastify/Next.js Route Handler + webhook helpers (Stripe/Shopify/Lemon Squeezy/custom). K16 4-kanal producer compliant.
Maintainers
Readme
@gurulu/node
Server SDK for Gurulu — Truth Layer for product analytics.
Outcome verification, webhook ingestion, and framework middleware for Node.js / Bun.
Install
npm install @gurulu/node
# or
bun add @gurulu/nodeQuick start
import { createGurulu } from '@gurulu/node';
const gurulu = createGurulu({
workspace: 'pk_xxxxxxxxxxxx',
apiKey: process.env.GURULU_API_KEY,
});
// Server-truth event (verified outcome, not client-claimed)
await gurulu.track('purchase.completed', {
user_id: 'u_42',
order_id: 'o_123',
total: 49.99,
currency: 'USD',
});Framework middleware
// Express
import { guruluMiddleware } from '@gurulu/node/middleware/express';
app.use(guruluMiddleware({ workspace: 'pk_xxx' }));
// Fastify
import { guruluPlugin } from '@gurulu/node/middleware/fastify';
fastify.register(guruluPlugin, { workspace: 'pk_xxx' });
// Next.js (Route Handler)
import { guruluHandler } from '@gurulu/node/middleware/next';
export const POST = guruluHandler({ workspace: 'pk_xxx' });Webhook helpers
Signature-verified, automatically mapped to canonical events:
import { handleStripeWebhook } from '@gurulu/node/webhooks/stripe';
// Also: /webhooks/shopify, /webhooks/lemonsqueezy, /webhooks/custom
app.post('/webhooks/stripe', async (req, res) => {
const event = await handleStripeWebhook(req, {
secret: process.env.STRIPE_WEBHOOK_SECRET,
workspace: 'pk_xxx',
});
res.json({ ok: true });
});Features
- Outcome verification — browser claims
purchase_initiated; server confirmspurchase.completedas truth. - Webhook helpers — Stripe, Shopify, Lemon Squeezy with signature verify + canonical event mapping.
- Framework middleware — Express 4/5, Fastify 4/5, Next.js 14/15 Route Handlers.
- Type-safe — registry-bound event types via codegen.
Documentation
License
MIT — see LICENSE.
Copyright © 2026 MONAFY LTD (UK Company No. 17031485).
