Nyx

Nyx

0.22.0

Web framework

Rails-scoped web apps, written in Nox.

Application lifecycle, models, sessions, jobs and mail. Typed APIs, one SQLite file by default, the same deploy path as noxlang.com.

$noxc install github.com/mburakmmm/nyx@v0.22.0

Nox ≥ 2.0.7. The language itself is documented at noxlang.com.

nox
import nox.http
from nox.http import HttpRequest, HttpResponse
from nox.router import Context
import nyx.app
import nyx.config
import nyx.ctrl
import nyx.ctx
from nyx.app import Application
from nyx.config import Config
from nyx.ctx import AppContext

def setup(application: Application) -> None:
    def home(ctx: Context) -> HttpResponse:
        ac: AppContext = nyx.ctx.wrap(application, ctx)
        context: dict[str, str] = {}
        context["title"] = "Hello"
        context["env"] = ac.config().env
        return nyx.ctrl.render(200, "app/views/home.html", context)

    application.router.get("/", home)

cfg: Config = nyx.config.load()
application: Application = nyx.app.boot(cfg, setup)

def handle(req: HttpRequest) -> HttpResponse:
    return nyx.app.dispatch(application, req)

nox.http.serve(8080, handle)

Shape

The same idea, three different jobs.

Nyx is the full-stack web framework for Nox. It covers the Rails problem space: boot, routing, views, models, security and background work.

One package

Nyx is a Nox package, not a second compiler. Add it under requires, then import nyx.app.

Typed records

New code builds rows with Attributes. JSON-string create and update stay for older apps.

Boot once

Call nyx.app.boot at module scope and close handlers over the Application inside setup.

Surface

What you actually import.

Lifecycle

nyx.app, config, runtime, ctx

HTTP

routes, views, forms, params

Data

SQLite, Postgres and MySQL models

Security

sessions, CSRF, auth, JWT, CSP

Built on Nox, served next to it.

This site is a Nyx application on the same Cloudflare tunnel as noxlang.com. The language reference stays on the Nox site.