@secondlayer/shared

May 22, 2026 ยท View on GitHub

Foundational utilities for Second Layer services: DB layer (Kysely + postgres-js), Zod schemas, crypto (Standard Webhooks signing, AES-GCM secret envelope), logger, pricing, env/mode utils, Stacks node clients.

Testing

# Run tests (DB tests skip without DATABASE_URL)
bun test

# Run with database
DATABASE_URL=postgresql://postgres:postgres@localhost:5432/secondlayer_test bun test

Migrations

DATABASE_URL=... bun run migrate

Exports

PathDescription
@secondlayer/sharedCore utilities (errors, logger, env, db layer, subgraph/subscription schemas)
@secondlayer/shared/dbKysely database layer
@secondlayer/shared/db/schemaDatabase schema + row types
@secondlayer/shared/db/queries/*Query helpers (integrity, chain-reorgs, subgraphs, subgraph-gaps, subgraph-operations, subscriptions)
@secondlayer/shared/schemasZod schemas (subgraphs, subscriptions)
@secondlayer/shared/schemas/subgraphsSubgraph schemas
@secondlayer/shared/schemas/subscriptionsSubscription schemas
@secondlayer/shared/subgraphs/specSubgraph spec generation
@secondlayer/shared/queue/listenerPostgres LISTEN/NOTIFY helper (used for block notifications)
@secondlayer/shared/loggerLogger
@secondlayer/shared/errorsError types
@secondlayer/shared/modeINSTANCE_MODE dispatch (platform / dedicated / oss)
@secondlayer/shared/crypto/secretsAES-GCM secret envelope
@secondlayer/shared/crypto/standard-webhooksStandard Webhooks signing
@secondlayer/shared/nodeStacks node client
@secondlayer/shared/node/*Stacks node clients (hiro-client, local-client, hiro-pg-client, archive-client)