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

@upendra19/platform-sdk

v1.0.0

Published

SDK for bundling multiple REST APIs using Repository Pattern

Downloads

105

Readme

Platform SDK - Repository Pattern POC

A clean SDK demonstrating how to bundle multiple REST APIs using the Repository Pattern.

Architecture

1. HTTP Client Layer

  • HttpClient.js: Shared HTTP client handling authentication and error normalization
  • Accepts baseUrl and token in constructor
  • Adds Authorization header automatically
  • Normalizes errors across all requests

2. Repository Layer

  • UserRepository.js: Encapsulates all user-related endpoints
  • PostRepository.js: Encapsulates all post-related endpoints
  • Hides endpoint paths from consumers
  • Each repository focuses on a single domain

3. SDK Facade

  • index.js: Main entry point (PlatformSDK class)
  • Initializes HTTP client once
  • Exposes repositories as properties: sdk.users, sdk.posts
  • Simple, clean API surface

Usage

const PlatformSDK = require('./sdk');

const sdk = new PlatformSDK({
  baseUrl: 'https://jsonplaceholder.typicode.com',
  token: 'your-api-token',
});

// Use repository methods
const users = await sdk.users.getAllUsers();
const posts = await sdk.posts.getAllPosts();
const user = await sdk.users.getUserById(1);

Run Example

node example.js

Publishing as Private NPM Package

Option 1: Private NPM Registry

# Set registry to your private NPM
npm config set registry https://your-registry.com

# Publish
npm publish

Option 2: GitHub Packages

# Add to package.json
{
  "publishConfig": {
    "registry": "https://npm.pkg.github.com"
  }
}

# Authenticate
npm login --registry=https://npm.pkg.github.com

# Publish
npm publish

Option 3: Verdaccio (Self-hosted)

# Install Verdaccio
npm install -g verdaccio

# Run registry
verdaccio

# Publish to local registry
npm publish --registry http://localhost:4873

Installing the Private SDK

# From private registry
npm install @yourcompany/platform-sdk --registry https://your-registry.com

# From GitHub Packages
npm install @yourcompany/platform-sdk

# From tarball
npm install /path/to/yourcompany-platform-sdk-1.0.0.tgz

Benefits of This Architecture

  • Separation of Concerns: HTTP logic separated from business logic
  • Easy Testing: Mock repositories independently
  • Scalability: Add new repositories without changing existing code
  • Consistent API: All endpoints accessed through unified interface
  • Type Safety: Easy to add TypeScript types later
  • Private Distribution: Control who accesses your APIs

Extending the SDK

To add a new domain (e.g., Comments):

  1. Create sdk/repositories/CommentRepository.js
  2. Add to SDK facade in sdk/index.js:
    this.comments = new CommentRepository(httpClient);
  3. Use it: sdk.comments.getAllComments()