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

@mpratyush54/sdk-node

v1.0.3

Published

Platform Node.js SDK - Auto-registration, metrics, logging, config, storage, DB connections

Downloads

34

Readme

@mpratyush54/sdk-node

Official Node.js SDK for Platform — auto-registration, GitOps, metrics, logging, config, storage, and managed DB connections.

Requires Node.js ≥ 18. Package: @mpratyush54/sdk-node

Install

npm install @mpratyush54/sdk-node

Quick start

import platform from '@mpratyush54/sdk-node';
// or: import { PlatformClient } from '@mpratyush54/sdk-node'; const platform = new PlatformClient();

await platform.init({
  projectName: 'my-api',
  platformUrl: process.env.PLATFORM_URL,      // e.g. https://api.example.sslip.io
  sdkToken: process.env.PLATFORM_SDK_TOKEN,   // Project → Tokens
  environmentName: process.env.ENVIRONMENT_NAME || 'development',
  databases: ['postgres', 'mongo', 'redis'],  // optional — platform ensures DBs
});

const app = express();
app.use(platform.expressMiddleware()); // per-route latency → portal

platform.logger.info('ready');

What init() does

  1. Register the service (POST /api/sdk/register)
  2. Optionally wire GitOps (ArgoCD) when repositoryUrl is set — SDK git origin must match the project repo
  3. Ensure Postgres / Mongo / Redis credentials for the project environment
  4. Start heartbeats (CPU, memory, uptime, DB health)
  5. Load remote config and refresh in the background
  6. Connect DB managers listed in databases

The Kubernetes namespace is assigned by the server ({project}-{environment}). Client namespace is ignored.

Options (PlatformOptions)

| Option | Required | Description | |--------|----------|-------------| | projectName | yes | Platform project name | | platformUrl | yes | API base URL | | sdkToken | no* | Bearer token (PLATFORM_SDK_TOKEN env fallback) | | environmentName | no | Default development | | version / branch / commitSha | no | Build metadata | | databases | no | ['postgres','mongo','redis'] | | repositoryUrl | no | Must match project repositoryUrl for GitOps | | gitPath / gitRevision | no | Manifest path + revision for ArgoCD | | domain / serviceName / servicePort | no | Ingress wiring | | gitops | no | Prefer GitOps path when repo is set |

*Required for authenticated register / DB ensure / metrics on secured APIs.

Features

Express / Fastify-style middleware

app.use(platform.expressMiddleware());

Logging

platform.logger.info('hello', { userId: 1 });
platform.logger.warn('slow');
platform.logger.error('failed', { err: String(e) });

Optional Winston / Pino transports:

import { createWinstonTransport, createPinoTransport } from '@mpratyush54/sdk-node';

Console capture

platform.captureConsole(); // forwards console.* → platform logs

Avoid captureConsole() together with transports that also write to console (recursion). Prefer platform.logger in production APIs.

Databases

const { rows } = await platform.db.postgres.query('SELECT 1 AS ok');
await platform.db.mongo.db.collection('items').findOne({}); // mongoose Connection
await platform.db.redis.set('k', 'v', 60);

Managers: PostgresManager, MongoManager, RedisManager (also exported).

Config & storage

const flag = platform.config('FEATURE_X', false);
await platform.storage.upload(/* … */);

Shutdown

process.on('SIGTERM', () => platform.shutdown());

Examples

Runnable snippets live in examples/:

| File | Topic | |------|--------| | 01-express-basic.js | Init + middleware + health | | 02-express-databases.js | Postgres / Mongo / Redis | | 03-logging-metrics.js | Logger + custom metrics | | 04-gitops-register.js | GitOps register options |

End-to-end demo apps (Node + React + Angular on cluster): examples/sdk-apps/.

Docs: Node quickstart · PlatformClient API

Env vars

| Variable | Purpose | |----------|---------| | PLATFORM_URL | API base (your convention) | | PLATFORM_SDK_TOKEN | Default for sdkToken | | PLATFORM_PG_* / PLATFORM_MONGO_* / PLATFORM_REDIS_* | Optional local DB overrides |

License

MIT