aboutsummaryrefslogtreecommitdiff
path: root/library/lullaby/net.lua
diff options
context:
space:
mode:
authoramy <[email protected]>2025-04-14 14:09:22 -0500
committerGitHub <[email protected]>2025-04-14 14:09:22 -0500
commitdd7a8af4050454c3901987bff24a77334f892cc4 (patch)
tree48c6107656e14cfbbcbb49424fc3454de850a5db /library/lullaby/net.lua
parent44c68aa7d51ea6b50c442bfbfa4ce11c530d2f7d (diff)
parentdc7e4527e88ed0c59e17c0ff04c01e1c92136e42 (diff)
Merge pull request #1 from ameliasquires/new-config
updates how config values are updated, support for local values when copying states, and annotations
Diffstat (limited to 'library/lullaby/net.lua')
-rw-r--r--library/lullaby/net.lua166
1 files changed, 166 insertions, 0 deletions
diff --git a/library/lullaby/net.lua b/library/lullaby/net.lua
new file mode 100644
index 0000000..3f9abdc
--- /dev/null
+++ b/library/lullaby/net.lua
@@ -0,0 +1,166 @@
+---@meta
+
+---@class net
+local net = {}
+
+---@class server-table
+local server_table = {}
+
+---@class res-table
+local res_table = {}
+
+---sends value to client and closes socket
+---@param T res-table
+---@param value string
+function res_table.send(T, value) end
+
+---autosets Content-Type and sends contents of file to client and closes socket
+---@param T res-table
+---@param value string
+function res_table.sendfile(T, value) end
+
+---sends value to client and doesn't close the socket
+---@param T res-table
+---@param value string
+function res_table.write(T, value) end
+
+---closes socket
+---@param T res-table
+function res_table.close(T) end
+
+---prevents calling any other selected routes
+---@param T res-table
+function res_table.stop(T) end
+
+---key value table containing header values to be sent
+res_table.header = {}
+
+---@class req-table
+local req_table = {}
+
+---"roll" the request forward
+---@param T req-table
+---@param bytes integer | nil
+function req_table.roll(T, bytes) end
+
+---list of parameters in route
+req_table.parameters = {}
+
+---@deprecated
+req_table.client_fd = 0
+
+---@deprecated
+req_table._bytes = 0
+
+---@type integer
+req_table.ip = 0
+
+---@type string
+req_table.Body = ""
+
+---@type any|nil
+req_table.files = {}
+
+---@type any|nil
+req_table.cookies = {}
+
+
+---@param T server-table
+---@param route string
+---@param callback fun(res: res-table, req: req-table)
+function server_table.GET(T, route, callback) end
+
+---@param T server-table
+---@param route string
+---@param callback fun(res: res-table, req: req-table)
+function server_table.HEAD(T, route, callback) end
+
+---@param T server-table
+---@param route string
+---@param callback fun(res: res-table, req: req-table)
+function server_table.POST(T, route, callback) end
+
+---@param T server-table
+---@param route string
+---@param callback fun(res: res-table, req: req-table)
+function server_table.PUT(T, route, callback) end
+
+---@param T server-table
+---@param route string
+---@param callback fun(res: res-table, req: req-table)
+function server_table.DELETE(T, route, callback) end
+
+---@param T server-table
+---@param route string
+---@param callback fun(res: res-table, req: req-table)
+function server_table.CONNECT(T, route, callback) end
+
+---@param T server-table
+---@param route string
+---@param callback fun(res: res-table, req: req-table)
+function server_table.OPTIONS(T, route, callback) end
+
+---@param T server-table
+---@param route string
+---@param callback fun(res: res-table, req: req-table)
+function server_table.TRACE(T, route, callback) end
+
+---@param T server-table
+---@param route string
+---@param callback fun(res: res-table, req: req-table)
+function server_table.PATCH(T, route, callback) end
+
+---@param T server-table
+---@param route string
+---@param callback fun(res: res-table, req: req-table)
+function server_table.all(T, route, callback) end
+
+---@param server server-table
+local function listen_callback(server) end
+
+---@param callback fun(server: server-table)
+---@param port integer
+function net.listen(callback, port) end
+
+---creates an https request
+---@param url string
+---@param value string | nil
+---@param header table<string, string> | nil
+---@param request string | nil
+---@return table<string, string> | error
+function net.srequest(url, value, header, request) end
+
+---@class wss-table
+local wss = {}
+
+---@class wss-read
+local wss_read = {}
+
+---@type string
+wss_read.content = ""
+
+---@type integer
+wss_read.opcode = 0
+
+---reads oldest unread frame from server
+---@param T wss-table
+---@return wss-read | error
+function wss.read(T) end
+
+---sents data frame to server
+---@param T wss-table
+---@param data string
+---@return nil | error
+function wss.write(T, data) end
+
+---calls gc early
+---@param T wss-table
+---@return nil
+function wss.close(T) end
+
+---creates a wss connection
+---@param url string
+---@return wss-table | error
+function net.wss(url) end
+
+return net