bizwiz3/aura

The HTTP client for Lune. Aura is a lightweight wrapper around Lune's native net library for handling request. Inspired by Axios, it simplifies data fetching by handling JSON encoding/decoding, URL normalization, and standardized response objects automatically.

🌙 Aura

The HTTP client for Lune. Aura is a lightweight wrapper around Lune's native net library for handling request. Inspired by Axios, it simplifies data fetching by handling JSON encoding/decoding, URL normalization, and standardized response objects automatically.

✨ Features

Auto-JSON: Automatically encodes request bodies and decodes response bodies.

Zero-Lag Localhost: Automatically patches the Windows localhost IPv6 delay (2s → 4ms).

Safe Decoding: Uses pcall to ensure malformed JSON doesn't crash your runtime.

Standardized: Consistent response objects across all HTTP methods.

Installation

pesde add bizwis3/aura
pesde install

Quick Start

Basic GET Request

local aura = require("path/to/aura")
local res = aura.get({ url = "https://jsonplaceholder.typicode.com/posts/1" })

if res.ok then
    print(res.body.title) -- Already decoded into a table!
end

Basic POST Request

local res = aura.post({
    url = "http://localhost:8080/users",
    body = {
        name = "John Doe",
        job = "Lune Developer"
    }
})

API Reference

REQUEST CONFIGURATION (AuraRequest)

PropertyTypeDescription
urlstringThe target URL.
methodstringHTTP Method (GET, POST, etc).
bodytable or stringData to be sent. Tables are auto-JSON encoded.
headerstableCustom HTTP headers.
querytableURL Query parameters.
optionstableOptions

RESPONSE OBJECT (AuraResponse)

PropertyTypeDescription
okbooleantrue if the status code is 200-299.
statusnumberThe HTTP status code (e.g., 200, 404).
statusMessagestringThe status text from the server (e.g., "OK").
headerstableA dictionary of response headers.
bodyanyThe decoded JSON table or raw response string.

Example Errors

Aura Request got an issue:

 Status : 300 (Multiple Choices)
 Method : GET
 URL    : http://localhost:8080/
 Time   : 0.0019 seconds
Aura Request got an issue:

 Status : 404 (Not Found)
 Method : GET
 URL    : http://localhost:8080/notfound
 Time   : 0.0015 seconds