Skip to content

Cyntaax/fivem-webbed

Repository files navigation

Contributors Forks Stargazers Issues MIT License


FiveM Webbed


· Report Bug · Request Feature

About The Project

This is a library for creating RESTful web endpoints in FiveM server.

Features

  • 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 and POST for the time being

Getting Started

Simply download the Latest Release, place into your resources directory and start!

Prerequisites

  • Just a basic understanding of Lua and HTTP

Configuration

  • None Required outside of starting in the server.cfg
... (other resources)
ensure fivem-webbed

Usage

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
}

Roadmap

  • Include some pre-made middlewares
  • Lots of examples for different tasks

See the open issues for a list of proposed features (and known issues).

Contributing

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.

  1. Fork the Project
  2. Create your Feature Branch (git checkout -b feature/AmazingFeature)
  3. Commit your Changes (git commit -m 'chore: added some amazing feature')
  4. Push to the Branch (git push origin feature/AmazingFeature)
  5. Open a Pull Request

License

Distributed under the MIT License. See LICENSE for more information.

Notable Mentions

  • Async - Really helped for dealing with running all of the middlewares

Contact

Cyntaax - @cyntaax - [email protected]

Project Link: https://github.com/cyntaax/fivem-webbed

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages