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

owebjs

v1.4.2

Published

A flexible and modern web framework built on top of Fastify

Readme

Oweb

A flexible and modern web framework built on top of Fastify, designed for creating scalable and maintainable web applications with file-based routing and hot module replacement.

Features

  • File-based Routing: Automatically generate routes based on your file structure
  • Hot Module Replacement (HMR): Update your routes without restarting the server
  • Middleware Support: Use hooks to add middleware functionality
  • Error Handling: Global and route-specific error handling
  • TypeScript Support: Built with TypeScript for better developer experience
  • Plugin System: Extend functionality with plugins
  • uWebSockets.js Support: Optional high-performance WebSocket server

Installation

npm install owebjs

Quick Start

import Oweb from 'owebjs';

// Create and setup the app
const app = await new Oweb().setup();

// Load routes from a directory
await app.loadRoutes({
    directory: 'routes',
    hmr: {
        enabled: true, // Enable hot module replacement
    },
});

// Start the server
await app.start({ port: 3000 });
console.log('Server running at http://localhost:3000');

Creating Routes

Routes are automatically generated based on your file structure. Create a file in your routes directory:

// routes/hello.js
import { Route } from 'owebjs';

export default class extends Route {
    async handle(req, res) {
        res.send({ message: 'Hello, World!' });
    }
}

This will create a GET route at /hello.

Dynamic Routes

Use brackets to create dynamic route parameters:

// routes/users/[id].js
import { Route } from 'owebjs';

export default class extends Route {
    async handle(req, res) {
        res.send({ userId: req.params.id });
    }
}

This will create a GET route at /users/:id.

Parameter Validation with Matchers

Use matchers to validate dynamic route parameters:

// routes/users/[id=integer].js
import { Route } from 'owebjs';

export default class extends Route {
    async handle(req, res) {
        res.send({ userId: req.params.id });
    }
}
// matchers/integer.js
export default function (val) {
    return !isNaN(val);
}

Then configure Oweb to use your matchers directory:

await app.loadRoutes({
    directory: 'routes',
    matchersDirectory: 'matchers', // Directory containing custom matchers
    hmr: {
        enabled: true,
        matchersDirectory: 'matchers', // Optional: Enable HMR for matchers
    },
});

Now you can use your custom matchers in route filenames with the syntax [paramName=matcherName].

HTTP Methods

Specify the HTTP method in the filename:

// routes/api/users.post.js
import { Route } from 'owebjs';

export default class extends Route {
    async handle(req, res) {
        // Create a new user
        const user = req.body;
        res.status(201).send({ id: 1, ...user });
    }
}

Middleware (Hooks)

Create hooks to add middleware functionality:

// routes/_hooks.js
import { Hook } from 'owebjs';

export default class extends Hook {
    handle(req, res, done) {
        console.log(`${req.method} ${req.url}`);
        done(); // Continue to the next hook or route handler
    }
}

Hooks are applied to all routes in the current directory and its subdirectories.

Error Handling

Global Error Handler

app.setInternalErrorHandler((req, res, error) => {
    console.error(error);
    res.status(500).send({
        error: 'Internal Server Error',
        message: error.message,
    });
});

Route-specific Error Handler

import { Route } from 'owebjs';

export default class extends Route {
    async handle(req, res) {
        throw new Error('Something went wrong');
    }

    handleError(req, res, error) {
        res.status(500).send({
            error: 'Route Error',
            message: error.message,
        });
    }
}

Plugins

Oweb supports Fastify plugins and comes with some built-in plugins:

Using Fastify Plugins

import Oweb from 'owebjs';
import fastifyMultipart from '@fastify/multipart';

const app = await new Oweb().setup();

// Register Fastify plugin
await app.register(fastifyMultipart, {
    limits: {
        fileSize: 10 * 1024 * 1024, // 10MB
    },
});

Using Built-in Plugins

import { Route } from 'owebjs';
import { ChunkUpload } from 'owebjs/dist/plugins';

export default class extends Route {
    async handle(req, res) {
        const file = await req.file();
        const buffer = await file.toBuffer();

        await ChunkUpload(
            {
                buffer,
                fileName: file.filename,
                currentChunk: +req.query.currentChunk,
                totalChunks: +req.query.totalChunks,
            },
            {
                path: './uploads',
                maxChunkSize: 5 * 1024 * 1024, // 5MB
            },
        );

        return res.status(204).send();
    }
}

Advanced Configuration

uWebSockets.js Support

const app = await new Oweb({ uWebSocketsEnabled: true }).setup();

Custom Route Options

import { Route } from 'owebjs';

export default class extends Route {
    constructor() {
        super({
            schema: {
                body: {
                    type: 'object',
                    required: ['username', 'password'],
                    properties: {
                        username: { type: 'string' },
                        password: { type: 'string' },
                    },
                },
            },
        });
    }

    async handle(req, res) {
        // Body is validated according to the schema
        res.send({ success: true });
    }
}