Luna is a modern secure framework for creating high-performance servers in Lua (Lua 5.1 - 5.4/LuaJIT) and Python with a simple and elegant API. The Lunac client provides convenient interaction with the luna server. Create full-featured HTTP/HTTPS servers with robust routing and middleware support. With built-in WebSocket support, you can easily create real-time web applications. Open source code - Luna is released under the MIT license.
Luna provides all the necessary tools for creating modern server applications in Lua and Python
Optimized code for Lua 5.1, LuaJIT, and Python delivers maximum request processing speed up to 20,000 requests per second.
The Lunac client allows easy server connection and request sending with minimal code.
Automatic request parameter validation and DDoS protection.
Powerful routing system with support for prefixes and nested routers.
Support for asynchronous requests via noawait_fetch and synchronous via fetch.
Easily integrates with popular frameworks including LÖVE, Solar2d, and Python ecosystems.
Luna uses its own reliable UDP-based protocol, allowing messages of any size without data loss in 99.9% of cases.
With async=True, create asynchronous requests that run on a coroutine basis for simultaneous processing.
Luna uses TLS 1.3 algorithms, X25519 for key exchange, and ChaCha20 for encryption, ensuring secure message transmission.
A simple server and client written using Luna and Lunac in Lua or Python
-- Initializing Luna server and Lunac client
local luna, lunac
function love.load()
-- Loading server library
luna = require("luna")
-- Creating a new server application
local app = luna.new_app({
host = "127.0.0.1",
port = 8081,
name = "test server",
max_ip_connected = 20,
no_errors = true,
})
-- Creating main router with 'api' prefix
local main_router = app:new_router({
prefix = "api",
})
-- Creating /api/echo endpoint
main_router:new({
validate = {text = {"string","nil"}},
response_validate = {"string"},
prefix = "echo",
fun = function(args, client)
return args.text or "no text provided"
end
})
-- Loading client library
lunac = require("lunac")
_G.client = lunac.connect_to_app({
host = "127.0.0.1",
port = 8081,
name = "test server",
no_errors = true,
server = luna,
listener = function (message)
print("New message client:send ", message)
end
})
-- Asynchronous request
client:noawait_fetch("api/echo", function(data, err) end, {text = "hello world"})
-- Synchronous request
local response = client:fetch("api/echo", {text = "hello world"})
print("Echo data: "..response)
end
function love.update(dt)
-- Updating server and client
luna.update(dt)
lunac.update(dt)
end