@robinpath/server
v0.1.3
Published
HTTP server creation and management using Node.js built-in http module. Supports routing, static file serving, CORS, and common response helpers.
Readme
@robinpath/server
HTTP server creation and management using Node.js built-in http module. Supports routing, static file serving, CORS, and common response helpers.
Why use this module?
The server module lets you:
- Create a new HTTP server instance
- Start listening for incoming connections
- Stop the server and close all connections
- Register a handler for all incoming requests
- Register an error handler for the server
All functions are callable directly from RobinPath scripts with a simple, consistent API.
Installation
robinpath add @robinpath/serverQuick Start
No credentials needed — start using it right away:
server.startAvailable Functions
| Function | Description |
|----------|-------------|
| server.create | Create a new HTTP server instance |
| server.start | Start listening for incoming connections |
| server.stop | Stop the server and close all connections |
| server.onRequest | Register a handler for all incoming requests |
| server.onError | Register an error handler for the server |
| server.route | Add a route with method, path pattern, and handler |
| server.static | Serve static files from a directory |
| server.sendJson | Send a JSON response |
| server.sendHtml | Send an HTML response |
| server.sendFile | Send a file as the response |
| server.sendRedirect | Send an HTTP redirect response |
| server.status | Send a response with a specific status code |
| server.cors | Enable and configure CORS headers for a server |
| server.getServers | List all active server instances |
| server.getRoutes | List all routes registered on a server |
Examples
Start listening for incoming connections
server.startStop the server and close all connections
server.stopRegister a handler for all incoming requests
server.onRequestIntegration with RobinPath
import { RobinPath } from "@wiredwp/robinpath";
import Module from "@robinpath/server";
const rp = new RobinPath();
rp.registerModule(Module.name, Module.functions);
rp.registerModuleMeta(Module.name, Module.functionMetadata);
const result = await rp.executeScript(`
server.start
`);Full API Reference
See MODULE.md for complete documentation including all parameters, return types, error handling, and advanced examples.
Related Modules
@robinpath/json— JSON module for complementary functionality
License
MIT
