bizwiz3/nova

A filesystem-based web framework for Luau runtimes, with out-of-the-box support for Lune and Zune.

Nova logo

A filesystem-based web framework for Luau runtimes, with out-of-the-box support for Lune and Zune.

Table of Contents

Installation & Usage

Installation

Install Nova via the Pesde package manager:

pesde add bizwiz3/nova
pesde install

Usage

Manual Setup

  1. Create a src/ directory in your project root.
  2. Create an entry file (e.g., index.luau) inside src/ with the following code:
local Nova = require("@path/to/nova")

local app = Nova.new(8080)

app:listen() -- To run the server
  1. Create an app/ directory inside src/. This directory will house your routes.
  2. To create a route, add a route.luau file inside a directory within app/. The directory name becomes the base route.

For example, to create a route at /, create src/app/route.luau:

local Nova = require("@path/to/nova")

local App = {}

function App.Get()
    return Nova.response.json({ msg = "Hello, Nova" })
end

return App

The module must export properties named after HTTP methods: Get, Post, Put, Patch, and Delete. You can define them as functions:

local App = {}

App.Get = function()
    return Nova.response.json({ msg = "Hello, Nova" })
end

return App

Core Features

  • Filesystem Routing: Routes are automatically mapped to the directory structure of the app folder.
  • Pattern Matching: Native support for dynamic segments using [params] syntax.
  • Middleware Pipeline: Functional middleware chaining for global and route-specific logic.
  • Unified Response Utility: Standardized handling for JSON and HTML content types.
  • Environment Management: Automatic .env loading and process injection.
  • Integrated Logger: Colored terminal output for request monitoring and debugging.

Routing Conventions

Nova follows a predictable mapping from the filesystem to the URL path:

PathFilesystem Map
/src/app/route.luau
/userssrc/app/users/route.luau
/posts/
src/app/posts/[id]/route.luau

Middleware Chaining

Utilize the chain helper to apply logic sequentially before a request reaches the final handler:

-- route.luau
local Nova = require("@path/to/nova")

local function validate(req, next)
    if not req.headers["x-api-key"] then
        return Nova.response.json({ error = "Forbidden" }, { status = 403 })
    end
    next()
end

Route.Get = Nova.chain({ validate }, function(req)
    return Nova.response.json({ data = "Authorized access" })
end)

More info about middlewares soon.