top | item 47129169

Show HN: Nova – A Web Framework for Erlang, Elixir, and LFE on the Beam

1 points| taure | 7 days ago |github.com

Nova is an OTP-native web framework that works with Erlang, Elixir, and LFE. Since all three compile to the same BEAM bytecode, you can mix languages freely within one app.

Controllers are plain functions that take a request map and return tuples:

Erlang:

create(#{json := Params}) -> CS = kura_changeset:cast(pet, #{}, Params, [name, species]), CS1 = kura_changeset:validate_required(CS, [name, species]), case my_repo:insert(CS1) of {ok, Pet} -> {status, 201, #{}, #{data => Pet}}; {error, Changeset} -> {status, 422, #{}, #{errors => Changeset}} end.

Elixir:

def create(%{json: params}) do cs = :kura_changeset.cast(:pet, %{}, params, [:name, :species]) cs = :kura_changeset.validate_required(cs, [:name, :species]) case MyRepo.insert(cs) do {:ok, pet} -> {:status, 201, %{}, %{data: pet}} {:error, changeset} -> {:status, 422, %{}, %{errors: changeset}} end end

Getting started with Elixir (Mix):

mix archive.install hex nova_new mix nova.new my_app iex -S mix

Getting started with Erlang (Rebar3):

rebar3 new nova my_app cd my_app rebar3 nova serve

The ecosystem includes Kura (an Ecto-inspired database layer with schemas, changesets, and migrations), WebSocket support, distributed pub/sub via OTP's pg module, OpenTelemetry integration, code generators, and OpenAPI spec generation.

We recently published The Nova Book (https://novaframework.github.io/nova-book), a step-by-step guide to building a full app from scratch. There's also a pet_store example (https://github.com/Taure/pet_store) showing a complete REST API with Nova + Kura.

On Hex: https://hex.pm/packages/nova (v0.13.7, Apache 2.0)

discuss

order

No comments yet.