·
Report Bug
·
Request Feature
This is a library for creating RESTful web endpoints in FiveM server.
- Familiar API to those that have worked with express.js
- Automatic conversion of tables to data in responses
- Object-Oriented approach makes things easier and self-documenting
- Middleware functions can be used! (see example)
- Supports only
GET
andPOST
for the time being
Simply download the Latest Release, place into your resources directory and start!
- Just a basic understanding of Lua and HTTP
- None Required outside of starting in the server.cfg
... (other resources)
ensure fivem-webbed
The resource alone does nothing. It is a library to be included with another resource to create http endpoints/server files:
--- fxmanifest.lua
server_scripts {
'@fivem-webbed/server/server.lua',
'server/server.lua'
}
--- assume resource is named (api). Looks nice for the URL
--- server/server.lua
local player = Router.new()
player:Get("/:playerId", function(req, res)
local target = tonumber(req:Param("playerId"))
print('Player name', GetPlayerName(target))
return 200, {
name = GetPlayerName(target),
target = target
}
end)
Server.use("/players", player)
Server.listen()
curl -X GET http://localhost:30120/api/players/1
{
"name": "Cyntaax",
"target": 1
}
- Include some pre-made middlewares
- Lots of examples for different tasks
See the open issues for a list of proposed features (and known issues).
Contributions are what make the open source community such an amazing place to be learn, inspire, and create. Any contributions you make are greatly appreciated.
- Fork the Project
- Create your Feature Branch (
git checkout -b feature/AmazingFeature
) - Commit your Changes (
git commit -m 'chore: added some amazing feature'
) - Push to the Branch (
git push origin feature/AmazingFeature
) - Open a Pull Request
Distributed under the MIT License. See LICENSE
for more information.
- Async - Really helped for dealing with running all of the middlewares
Cyntaax - @cyntaax - [email protected]
Project Link: https://github.com/cyntaax/fivem-webbed