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

@odatano/nightgate

v0.1.2

Published

CAP Plugin — Midnight Blockchain Indexer with OData V4 API

Downloads

308

Readme

@odatano/nightgate

CAP Plugin - Midnight Blockchain Indexer with OData V4 API

npm License Tests Coverage

@odatano/nightgate is a self-contained Midnight blockchain indexer packaged as an SAP CAP plugin. It connects directly to a Midnight node over Substrate JSON-RPC WebSocket, normalizes chain data into CAP entities, and exposes it through OData V4 services.

This project integrates with the Midnight Network. For more information about the Midnight Network, please visit their website: Midnight Network.

Midnight Node (local ws://localhost:9944 or remote wss://rpc.preprod.midnight.network/)
    |
    | Substrate RPC / WebSocket
    v
MidnightNodeProvider
    |
    | Catch-up, live sync, retry, reorg detection
    v
Crawler + BlockProcessor
    |
    | Atomic persistence via CAP DB API
    v
SQLite / CAP Database
    |
    | OData V4
    v
NightgateService / NightgateIndexerService / Analytics / Admin

Highlights

| Capability | Details | |---|---| | Direct node indexing | Connects over ws:// or wss://; no external indexer required | | CAP plugin auto-registration | Registers db/ and srv/ models automatically through cds-plugin.js | | Catch-up plus live sync | Indexes historical finalized blocks, then subscribes to new heads | | Reorg handling | Detects parent-hash mismatches, rolls back affected data, records ReorgLog | | OData API | Blockchain, indexer, analytics, and admin services | | Operational endpoints | Health, readiness, liveness, reorg history, Prometheus-style metrics | | Wallet sessions | connectWallet / disconnectWallet with encrypted viewing-key storage | | Offline mode | CAP app starts even if the node is unreachable |

Version 0.1.2 is a read-side first release. Transaction build/sign/submit flows are not yet included.

Quick Start

Preprod (default — no Docker needed)

npm ci
npm run dev

Nightgate defaults to Preprod with the public RPC at wss://rpc.preprod.midnight.network/. No .env or extra config required.

Testnet with local Docker node

npm ci
docker compose -f docker/docker-compose.yml up -d

Create a .env in the repo root:

NIGHTGATE_NETWORK=testnet
NIGHTGATE_NODE_URL=ws://localhost:9944
npm run dev

Use as a CAP plugin

cd my-cap-app
npm install @odatano/nightgate @cap-js/sqlite

Add to package.json:

{
  "cds": {
    "requires": {
      "db": { "kind": "sqlite" },
      "nightgate": { "kind": "nightgate" }
    }
  }
}

Then cds watch. Defaults to Preprod. Override via env vars or CDS config:

| Env var | CDS config key | Default | |---|---|---| | NIGHTGATE_NETWORK | network | preprod | | NIGHTGATE_NODE_URL | nodeUrl | wss://rpc.preprod.midnight.network/ | | NIGHTGATE_CRAWLER_NODE_URL | crawler.nodeUrl | same as nodeUrl |

If switching an existing DB to a different network, delete db/midnight.db* first.

Query The API

# Latest blocks
curl "http://localhost:4004/api/v1/nightgate/Blocks?$top=5&$orderby=height desc"

# Indexer health
curl "http://localhost:4004/api/v1/indexer/getHealth()"

# Prometheus-style metrics
curl "http://localhost:4004/api/v1/indexer/getMetrics()"

Services

| Service | Path | |---|---| | NightgateService | /api/v1/nightgate | | NightgateIndexerService | /api/v1/indexer | | NightgateAnalyticsService | /api/v1/analytics | | NightgateAdminService | /api/v1/admin |

Documentation

  • Quickstart Guide: step-by-step from zero to first API call
  • Reference: configuration, runtime behavior, full API surface, project structure
  • Release 0.1.2: prepared GitHub/npm release notes and publish checklist
  • Changelog: list of notable changes by version

Development

npm run dev         # Start with auto-reload
npm run lint        # ESLint
npm run typecheck   # TypeScript check
npm run cds:types   # Regenerate @cds-models
npm test            # Full test suite with coverage

License

Apache-2.0

Links