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

objective-http

v2.1.6

Published

Proxy classes for creating a http server

Readme

objective-http

Proxy classes for creating a http server

Server

There are all Server classes feature.
Your endpoints should implement Endpoint class interface (get route() and async handle(request) methods).
Also you can add own handlers (implements handle(reqestStream, responseStream)).
Handler is a top level logic object, who intrreact with IO streams directly.
options is a node:http options, who pass when server starting.

const http = require('node:http');
const console = require('node:console');
const {
    Server,
    handler: {
        endpoint: {
            EndpointHandler,
            EndpointsHandler,
            EndpointHandlers,
            EndpointRequiredHandler,
        },
        error: {
            LogErrorHandler,
            UnexpectedErrorHandler,
            InvalidRequestErrorHandler,
            HandlerNotFoundErrorHandler,
        },
    },
    request: {
        chunk: { JsonServerRequest, ChunkServerRequest },
    },
    response: {
        chunk: { JsonServerResponse, ChunkServerResponse },
    },
} = require('objective-http').server;

new Server({
    handler: new UnexpectedErrorHandler({
        origin: new LogErrorHandler({
            origin: new InvalidRequestErrorHandler({
                origin: new HandlerNotFoundErrorHandler({
                    origin: new EndpointRequiredHandler({
                        origin: new EndpointHandlers({
                            handlers: [
                                new EndpointHandler({
                                    endpoint: new MyEndpoint(),
                                    request: new ChunkServerRequest({}),
                                    response: new ChunkServerResponse({}),
                                }),
                                new EndpointHandler({
                                    endpoint: new MyEndpoint(),
                                    request: new ChunkServerRequest({}),
                                    response: new ChunkServerResponse({})
                                }),
                                new EndpointsHandler({
                                    endpoints: [
                                       new MyJsonEndpoint(),
                                       new MyJsonEndpoint(),
                                       new MyJsonEndpoint(),
                                    ],
                                    request: new JsonServerRequest({
                                        origin: new ChunkServerRequest({}),
                                    }),
                                    response: new JsonServerResponse({
                                        origin: new ChunkServerResponse({}),
                                    }),
                                }),
                            ],
                        }),
                    }),
                    response: new ChunkServerResponse({}),
                }),
                response: new ChunkServerResponse({}),
            }),
            logger: console,
        }),
        response: new ChunkServerResponse({}),
    }),

    options: { port: 8080 },
    http,
});

or jsut use autoconfig.

const { server } = require('objective-http').server.autoconfig;
const { env } = require('ndoe:process');

server({ env, endpoints });

MyEndpoint class example:

class MyEndpoint {
    route = {
        method: 'GET',
        path: '/test'
    }

    async handle(request) {
        try {
            const processResult = await someProcess();

            return {
                status: 200,
                body: processResult.toString()
            };
        
        } catch (e) {
            return {
                status: 404,
                body: 'process does not found anything'
            };
        }
    }
}

Client

Simple wrapper for requests. options passing into http.request(oprions, ...)

const http = require('node:http');
const {
    request: {
        chunk: { JsonClientRequest, ChunkClientRequest },
    },
    response: {
        chunk: { JsonClientResponse, ChunkClientResponse },
    },
} = require('objective-http').client;

const request = new JsonClientRequest({
    origin: new ChunkClientRequest({
        http: http,
        response: new JsonClientResponse({
            origin: new ChunkClientResponse({})
        }),
    }),
});

const response = await request
    .with({
        options: {
            host: 'localhost',
            port: 80,
            method: 'GET',
            path: '/test',
        },
        body: { some: 'body' }
    })
    .send()

console.log(JSON.stringify(response.body));