Modules@robinpath/http

@robinpath/http

0.1.0Public

HTTP server for RobinPath scripts. Register routes with static responses (JSON, HTML, files), enable CORS, serve static directories. No callbacks needed.

@robinpath/http

HTTP server for RobinPath scripts. Register routes with static responses (JSON, HTML, files), enable CORS, serve static directories. No callbacks needed.

Category Functions Auth License

Why use this module?

The http module lets you:

  • Create a new HTTP server instance (does not start listening yet)
  • Register a GET route that returns static JSON data
  • Register a POST route that returns static JSON data
  • Register a PUT route that returns static JSON data
  • Register a DELETE route that returns static JSON data

All functions are callable directly from RobinPath scripts with a simple, consistent API.

Installation

npm install @robinpath/http

Quick Start

No credentials needed — start using it right away:

any "myapi" "/api/products" [{"id": 1}]

Available Functions

FunctionDescription
http.createServerCreate a new HTTP server instance (does not start listening yet)
http.getRegister a GET route that returns static JSON data
http.postRegister a POST route that returns static JSON data
http.putRegister a PUT route that returns static JSON data
http.deleteRegister a DELETE route that returns static JSON data
http.htmlRegister a GET route that serves an HTML string
http.fileRegister a GET route that serves a file from disk
http.redirectRegister a route that redirects to another URL
http.staticRegister a directory to serve static files from
http.corsEnable CORS on the server
http.listenStart the HTTP server listening for requests
http.stopStop the HTTP server gracefully
http.statusGet server status: port, routes, listening state, request count
http.logsGet the request log for a server

Examples

Register a GET route that returns static JSON data

any "myapi" "/api/products" [{"id": 1}]

Register a POST route that returns static JSON data

any "myapi" "/api/products" {"created": true}

Register a PUT route that returns static JSON data

any "myapi" "/api/products/:id" {"updated": true}

Integration with RobinPath

import { RobinPath } from "@wiredwp/robinpath";
import Module from "@robinpath/http";

const rp = new RobinPath();
rp.registerModule(Module.name, Module.functions);
rp.registerModuleMeta(Module.name, Module.functionMetadata);

const result = await rp.executeScript(`
  any "myapi" "/api/products" [{"id": 1}]
`);

Full API Reference

See MODULE.md for complete documentation including all parameters, return types, error handling, and advanced examples.

Related Modules

License

MIT

Versions (1)

VersionTagPublished
0.1.0latestyesterday
Install
$ robinpath install @robinpath/http
Version0.1.0
LicenseMIT
Unpacked Size7.4 KB
Versions1
Weekly Downloads0
Total Downloads0
Stars0
Last Publishyesterday
Createdyesterday

Category

web