Hello MTA community!
My name is Ehsan/Exxon
I’m excited to share a project I’ve been working on: mtasa-nestjs – a high-level API server framework for MTA:SA, inspired by Express.js and NestJS.
What is mtasa-nestjs?
mtasa-nestjs is a modular, structured Lua framework that makes building server-side APIs for MTA:SA simpler and more scalable. It brings modern backend patterns like Controllers, Middlewares, Guards, Interceptors, and DTOs directly into MTA:SA resources.
It’s perfect for developers who want to build secure, maintainable, and professional APIs for their game servers.
Key Features
Express.js / NestJS-inspired structure: Clear separation of concerns for Controllers, Middlewares, Guards, and Interceptors.
JWT Authentication & Password Hashing: Built-in secure JWT (HS256) implementation and password hashing from scratch.
DTO Support: Validate and structure input data for cleaner code.
Middlewares & Guards: Handle CORS, JSON parsing, authentication, authorization, and more.
No External Dependencies: Works out-of-the-box in Lua for MTA:SA.
Why I Built This
Many MTA:SA servers handle HTTP requests in an ad-hoc manner, often leading to messy and hard-to-maintain code. With mtasa-nestjs, you can structure your API like a professional backend framework, making your server easier to scale and maintain.
Example Usage
Creating a JWT Token:
local token = jwt.encode({userId = 123, role = "admin"}, "SECRET_KEY")
iprint(token)
Protecting Endpoints with Guards:
AuthGuard = function(ctx)
local authHeader = ctx.headers["authorization"]
if not authHeader then error(Exception.Unauthorized("Missing Authorization header")) end
local token = authHeader:match("^Bearer%s+(.+)$")
local payload = jwt.verify(token, "SECRET_KEY")
ctx.user = payload return true
end
Why You Should Try It
If you’ve ever wanted a clean, structured, and modern API architecture for your MTA:SA server, this is a great starting point.
It’s fully modular, fully Lua-based, and ready to handle complex server-side logic with minimal fuss.
Where to Get It
Ready on my github repository called mtsa-nestjs
Make sure to create your own controllers, guards and etc.
I’d love to hear feedback from the community. If you try it out, let me know what features you find most useful or what could be improved.
Happy coding!