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

@anby/platform-sdk

v1.3.0

Published

Runtime SDK for building services and apps that plug into the Anby Platform — auth, events, config

Readme

@anby/platform-sdk

SDK runtime mà mọi service Anby (và mọi app được cài thêm) dùng để cắm vào platform. Package này gói gọn ba concern xuyên suốt mà nếu không có nó thì mỗi service sẽ phải tự viết lại:

  1. Auth — verify JWT đến từ anby-auth-service và verify các request service-to-service ký bằng HMAC.
  2. Events — publish / subscribe event bus của platform qua transport có thể thay thế.
  3. Config — một entry point configurePlatform() duy nhất để các service boot đồng nhất.

Phụ thuộc vào @anby/contracts để dùng envelope sự kiện đã được type sẵn.

Cài đặt

{
  "dependencies": {
    "@anby/platform-sdk": "file:../../packages/platform-sdk",
    "@anby/contracts":   "file:../../packages/contracts"
  }
}

Cách dùng

Bootstrap

import { configurePlatform, configureAuth, configureEventTransport, PostgresEventTransport } from '@anby/platform-sdk';

configurePlatform({ serviceName: 'org-chart', tenantResolver });
configureAuth({ jwtPublicKey: process.env.AUTH_PUBLIC_KEY!, hmacSecret: process.env.SVC_HMAC_SECRET! });
configureEventTransport(new PostgresEventTransport(process.env.DATABASE_URL!));

Xác thực request

import { requireAuth, type AuthUser } from '@anby/platform-sdk';

app.get('/me', requireAuth(), (req, res) => {
  const user = (req as any).user as AuthUser;
  res.json(user);
});
  • verifyJwt(token) — verify token của end-user.
  • verifyHmac(req) — verify chữ ký service-to-service.
  • authenticateRequest(req) — thử JWT trước, fallback sang HMAC.
  • requireAuth() — middleware kiểu Express/Remix, trả 401 nếu fail.

Publish một event

import { createEvent, publishEvent } from '@anby/platform-sdk';

await publishEvent(createEvent({
  type: 'org.node.created',
  tenantId,
  actor: { userId, email },
  data: { nodeId, parentId },
}));

Các transport có sẵn:

  • InMemoryTransport — dùng cho test và local dev.
  • PostgresEventTransport — ghi vào bảng outbox để anby-event-router tiêu thụ.

Cấu trúc

src/
├── auth/      Verify JWT + HMAC, middleware auth
├── events/    Builder envelope sự kiện + transport có thể thay thế
├── config/    configurePlatform / getPlatformConfig
└── index.ts   Public API — chỉ import từ đây

Scripts

npm run build    # tsc
npm run test     # vitest

Độ ổn định

Chưa đạt 1.0. Public API là tất cả những gì được re-export từ src/index.ts; mọi thứ khác đều là nội bộ và có thể thay đổi mà không báo trước.