objective-http is a Node.js library that provides Object-Oriented Programming (OOP) proxy classes for constructing HTTP servers. It wraps Node.js's native `http` module, abstracting away low-level stream interactions into a more structured, class-based API. The library emphasizes a clear separation of concerns, allowing developers to define server logic through `Endpoint` classes (for route and request handling) and `Handler` classes (for error handling and request/response stream processing). Currently stable at version 2.1.6, the package appears to have a fairly active release cadence with frequent patch updates. It differentiates itself by offering a highly modular and extensible architecture for building HTTP services, including an `autoconfig` feature for simpler server setups, contrasting with more opinionated frameworks or purely functional approaches.
npm install objective-httpVerified import paths — ran on the pinned version, not inferred.
This quickstart demonstrates setting up a basic HTTP server using `objective-http`'s `autoconfig` utility, defining a simple GET endpoint, and starting the server.
Review the README and source code for the correct import paths and destructuring patterns. Update `require()` calls to match the new module structure.
For versions 1.x, you would need to implement custom JSON parsing/serialization. For versions 2.x and above, `JsonServerRequest` and `JsonServerResponse` have been re-added, but verify their usage patterns as they might differ from pre-1.4.0 versions.
Prefer the `autoconfig` utility for simpler server setups. When building custom server configurations, carefully follow the provided examples for destructuring the `objective-http.server` object to access nested components.
Always ensure the `endpoints` array contains valid instances of classes implementing the `Endpoint` interface (with `route` and `handle` methods). Pass `process.env` or a compatible object as the `env` parameter.
Use the correct CommonJS `require` statement: `const { Server } = require('objective-http').server;`The primary entry point for server components is usually `require('objective-http').server`. Avoid direct path imports like `require('objective-http/server')` unless explicitly documented.Ensure that any custom `Endpoint` classes are properly defined and instantiated before being passed to the server configuration. For example, `class MyEndpoint { ... }`.No dependency data recorded yet.