Licence
MIT
Version
0.1.0
Deps
0
Size
8 kB
Vulns
0
Weekly
0
@nova-lang/http
Nova HTTP client library — fetch-based request helpers, URL utilities, status code helpers, and auth patterns.
Install
npm install @nova-lang/http
Usage
@use "nova/http"
Requests
| Function | Description |
|---|---|
http-get(url, opts) |
GET request |
http-get-json(url, opts) |
GET and parse JSON response |
http-get-text(url, opts) |
GET and return text |
http-get-buffer(url, opts) |
GET and return ArrayBuffer |
http-post(url, body, opts) |
POST request |
http-post-json(url, data, opts) |
POST with JSON body |
http-post-form(url, data, opts) |
POST with form-encoded body |
http-put(url, body, opts) |
PUT request |
http-put-json(url, data, opts) |
PUT with JSON body |
http-patch(url, body, opts) |
PATCH request |
http-patch-json(url, data, opts) |
PATCH with JSON body |
http-delete(url, opts) |
DELETE request |
http-delete-json(url, opts) |
DELETE and parse JSON response |
http-request(url, opts) |
Raw request with full options |
http-fetch(url, opts) |
Direct fetch wrapper |
Status Codes
| Function | Description |
|---|---|
http-ok(status) |
Check if 2xx |
http-redirect(status) |
Check if 3xx |
http-client-error(status) |
Check if 4xx |
http-server-error(status) |
Check if 5xx |
http-status-text(status) |
Get human-readable status text |
Headers
| Function | Description |
|---|---|
http-headers(obj) |
Create Headers object |
http-header-get(headers, name) |
Get header value |
http-header-set(headers, name, value) |
Set header |
http-header-has(headers, name) |
Check header exists |
http-header-delete(headers, name) |
Delete header |
URL Utilities
| Function | Description |
|---|---|
http-url-parse(url) |
Parse URL into object |
http-url-encode(str) |
Encode URL component |
http-url-decode(str) |
Decode URL component |
http-url-params(obj) |
Create URLSearchParams |
http-url-params-string(obj) |
Encode params as string |
http-url-join(base, path) |
Join URL paths |
http-url-query(url, params) |
Add query params to URL |
Content Type Detection
| Function | Description |
|---|---|
http-is-json(headers) |
Check if response is JSON |
http-is-form(headers) |
Check if response is form |
http-is-html(headers) |
Check if response is HTML |
Auth
| Function | Description |
|---|---|
http-basic-auth(username, password) |
Basic auth header value |
http-bearer-auth(token) |
Bearer auth header value |
http-auth-header(scheme, credentials) |
Custom auth header |
License
MIT