🌟 Lumenite Framework Wiki
Lumenite is a high-performance C++/Lua web framework offering routing, sessions, JSON, HTTP client, template rendering, and built-in middleware. Designed for rapid development with Lua scripting on a native backend.
Here's the 📂 Scaffold section for the Lumenite Framework Wiki — describing how to create a new Lumenite project structure using --new:
📂 Scaffold
🛠 new <ProjectName>
Lumenite includes a built-in scaffolding tool to create a new web app layout quickly:
./<lumenite> new Test
You can immediately run your app with:
cd Test
./<lumenite>
📦 Modules
| Module | Description | Docs |
|---|---|---|
lumenite.db |
Full-featured SQLite3 wrapper for Lua. | View Docs |
lumenite.crypto |
Secure cryptographic module for Lua. | View Docs |
lumenite.safe |
Input sanitization and escaping utilities | View Docs |
Usage:
local db = require("lumenite.db")
🧭 Routing
app:get(path, handler) / app:post / app:put / app:delete
Registers a route handler:
app:get("/hello", function(req)
return "Hello, world!"
end)
📥 Request Object
Every route gets a structured req table:
---@class Request
---@field method string
---@field path string
---@field body string
---@field headers table<string, string>
---@field query table<string, string|string[]>
---@field form table<string, string|string[]>
---@field remote_ip string
Query & Form Auto-Coercion
- Booleans:
?debug=true→req.query.debug == true - Numbers:
?limit=10→req.query.limit == 10
Supports:
- Repeated values:
?tag=lua&tag=c++→req.query.tag = { "lua", "c++" }
📦 JSON Support
local tbl = app.json('{"hello": "world"}')
local back = app.jsonify(tbl)
app.json(str)orapp.from_json(str)app.jsonify(table)→ returns{ status = 200, body = "...", headers = ... }
🧠 Sessions
app.session_set("key", "value")
local value = app.session_get("key")
Session is backed by cookies (LUMENITE_SESSION) and is automatically available.
🖼️ Template Rendering
return app.render_template("index.html", { name = "Admin" })
Or use:
return app.render_template_string("<h1>Hello {{ name }}</h1>", { name = "Admin" })
🧩 Template Filters
app.template_filter("upper", function(val)
return string.upper(val)
end)
app.template_filter("safe", function(val)
return require("LumeniteSafe").escape(val)
end)
Usage: {{ username | upper }}
🔀 Middleware
app.before_request(req)
app.before_request(function(req)
if req.path == "/admin" and not req.headers["Authorization"] then
return { status = 401, body = "Unauthorized" }
end
end)
app.after_request(req, res)
app.after_request(function(req, res)
res.headers["X-Powered-By"] = "Lumenite"
res.headers["X-Host"] = req.remote_ip
return res
end)
🌐 HTTP Client
local res = app.http_get("https://api.ipify.org")
print(res.status, res.body)
📄 HTML Form Example
To test form submissions:
<form action="/submit" method="POST">
<input name="name" placeholder="Name">
<input name="email" type="email">
<input type="submit">
</form>
app:post("/submit", function(req)
return app.jsonify({ form = req.form })
end)
📁 send_file(path, options)
Returns a complete HTTP response that serves a file from disk. This is ideal for serving static files, downloadable assets, or binary content directly from Lua routes.
📦 Signature
send_file(path: string, options?: table): Response
🔧 Options Table
| Field | Type | Description |
|---|---|---|
as_attachment |
boolean | If true, sets Content-Disposition to attachment (forces download). |
download_name |
string | Suggested filename for download in the Content-Disposition header. |
content_type |
string | Override MIME type (auto-detected if omitted). |
status |
number | HTTP status code to use (default: 200). |
headers |
table | Custom headers to merge into the response. |
✅ Basic Example
app:get("/logo", function()
return send_file("static/logo.png")
end)
📥 As Download with Filename
app:get("/report", function()
return send_file("files/report.pdf", {
as_attachment = true,
download_name = "Monthly_Report.pdf",
headers = {
["Cache-Control"] = "no-store"
}
})
end)
🧠 Notes
- If
content_typeis not provided, the type is auto-detected from the file content and extension. - If the file is not found, it raises a Lua error.
- The file is read fully into memory — suitable for small to medium files.
🚀 Start the Server
app:listen(8080)
Made with ❤️ by Admin and Lumenite contributors.