You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Astra is a Rust based runtime environment for Lua (5.1-5.4), Luau and LuaJIT with native support for Teal. The goal is to get as much performance as possible while writing the logic in Lua instead for faster iteration, fault-tolerance and no-build requirements. This project is internally used here at ArkForge and many others.
Alternatively you can also install through cargo tool, if you have it installed:
cargo install lua-astra
Example
-- Create a new serverlocalserver=require("http").server.new()
-- Register a routeserver:get("/", function()
return"hello from default Astra instance!"end)
-- Configure the serverserver.port=3000-- Run the serverserver:run()
Or fancy some multi threaded async code
-- spawn an async task that does not block the running threadspawn_task(function ()
-- HTTP Request to check your IP addresslocalresponse=require("http").request("https://myip.wtf/json"):execute()
pprint(response:status_code())
pprint(response:remote_address())
pprint(response:body():json())
end)
What about some databases and serialization?
localmy_data=require("serde").json.decode('{"name": "John Astra", "age": 21}')
localdb=require("database").new("sqlite", ":memory:")
db:execute([[ CREATE TABLE IF NOT EXISTS data (id INTEGER PRIMARY KEY, name TEXT, age INTEGER) strict; INSERT INTO data (name, age) VALUES ($1, $2);]], { my_data.name, my_data.age })
pprint(db:query_all("SELECT * FROM data"))
There is also support for cryptography, datetime, jinja2, pubsub/observers, structure validation, async filesystem, and many more, check them at at the docs