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

@razvan11/paladin

v1.1.5

Published

A Bun-based backend framework with decorators, dependency injection, and controller registration

Readme

@razvan11/paladin

A modern, decorator-based backend framework for Bun with dependency injection, controller registration, and WebSocket support.

Features

  • Decorator-based routing - Clean, expressive route definitions
  • Dependency Injection - Powered by Inversify
  • Built for Bun - Leverages Bun's performance
  • WebSocket support - First-class WebSocket handling
  • React SSR - Server-side rendering utilities
  • Middleware support - Per-route middleware functions
  • Static file serving - Built-in asset handling

Installation

bun add @razvan11/paladin

Quick Start

import { App, controller, get, post, service, inject } from '@razvan11/paladin';

@service()
class UserService {
  getUsers() {
    return [{ id: 1, name: 'John' }];
  }
}

@controller('/users')
class UserController {
  constructor(@inject(UserService) private userService: UserService) {}

  @get('/')
  async list(c: Context) {
    return c.json(this.userService.getUsers());
  }

  @post('/')
  async create(c: Context) {
    const body = await c.req.json();
    return c.json({ created: body });
  }
}

const app = new App({ name: 'MyApp' });
app.registerController(UserController);
app.run();

Decorators

Controller Decorators

| Decorator | Description | |-----------|-------------| | @controller(prefix) | Marks a class as a controller with a route prefix | | @get(path, ...middlewares) | Handles GET requests | | @post(path, ...middlewares) | Handles POST requests | | @put(path, ...middlewares) | Handles PUT requests | | @patch(path, ...middlewares) | Handles PATCH requests | | @del(path, ...middlewares) | Handles DELETE requests | | @options(path, ...middlewares) | Handles OPTIONS requests | | @all(path, ...middlewares) | Handles all HTTP methods |

Service Decorators

| Decorator | Description | |-----------|-------------| | @service() | Marks a class as a service (singleton) | | @repository() | Marks a class as a repository (singleton) | | @database(options) | Marks a class as a database connection |

WebSocket Decorators

| Decorator | Description | |-----------|-------------| | @websocket(path) | Marks a class as a WebSocket handler | | @onMessage() | Handles incoming messages | | @onOpen() | Handles connection open | | @onClose() | Handles connection close | | @onDrain() | Handles backpressure drain |

Dependency Injection

Use the @inject() decorator to inject dependencies into your controllers and services:

@controller('/api')
class ApiController {
  constructor(
    @inject(UserService) private userService: UserService,
    @inject(AuthService) private authService: AuthService,
  ) {}
}

Middleware

Add middleware to individual routes:

const authMiddleware = async (c: Context, next: Next) => {
  const token = c.req.header('Authorization');
  if (!token) return c.json({ error: 'Unauthorized' }, 401);
  await next();
};

@controller('/protected')
class ProtectedController {
  @get('/', authMiddleware)
  async secure(c: Context) {
    return c.json({ message: 'Secret data' });
  }
}

WebSockets

import { websocket, onMessage, onOpen, onClose } from '@razvan11/paladin';

@websocket('/chat')
class ChatHandler {
  @onOpen()
  handleOpen(ws: ServerWebSocket) {
    console.log('Client connected');
  }

  @onMessage()
  handleMessage(ws: ServerWebSocket, message: string | Buffer) {
    ws.send(`Echo: ${message}`);
  }

  @onClose()
  handleClose(ws: ServerWebSocket) {
    console.log('Client disconnected');
  }
}

const app = new App({ name: 'ChatApp' });
app.registerWebSocket(ChatHandler);
app.run();

Static Files

const app = new App({ name: 'MyApp' });

app.serveStatic({
  path: '/static',
  root: './public'
});

Use the asset() helper to generate URLs:

import { asset } from '@razvan11/paladin';

asset('dist', 'app.js'); // Returns '/static/dist/app.js'

React SSR

Render React components on the server:

import { render, LayoutView } from '@razvan11/paladin';

@controller('/')
class IndexController {
  @get('/')
  index(c: Context) {
    return render(c, LayoutView, {
      title: 'My App',
      scripts: [asset('dist', 'app.js')],
      styles: [asset('dist', 'app.css')],
      children: <div id="root" />,
    });
  }
}

Configuration

const app = new App({
  name: 'MyApp',
  cors: ['https://example.com'], // CORS origins (default: ['*'])
  validators: myValidators, // Optional validators
});

Environment variables:

  • PORT - Server port (default: 3000)
  • APP_ENV - Environment mode (local, development, staging, production)

API Reference

App

| Method | Description | |--------|-------------| | registerController(Controller) | Register a controller class | | registerControllers(...Controllers) | Register multiple controllers | | registerWebSocket(WSHandler) | Register a WebSocket handler | | registerWebSockets(...WSHandlers) | Register multiple WebSocket handlers | | serveStatic(options) | Serve static files | | getAppInstance() | Get the underlying Hono instance | | run() | Start the server |

License

MIT © Razvan