Onyx Framework v0.4.0 released!

The latest release brings Crystal 0.28 support, brand new server testing API, fresh EDA update and better modularity. Many bugs were fixed and some were added.

General changes

Before:

Onyx.get "/", &.response.puts("Hello!")
Onyx.listen

After:

Onyx::HTTP.get "/", &.response.puts("Hello!")
Onyx::HTTP.listen

This change also applies both to Onyx::SQL and Onyx::EDA.

  • CI improvements – now every onyx* commit triggers many dependant repository builds, including crystalworld and onyx-todo-json-api, to catch bugs earlier

Onyx::HTTP changes

The appropriate version is now ~> 0.8.0.

  • Added Onyx::HTTP.on method to build tree-like structures (API docs):

Before:

Onyx.post "/users/", Endpoint::User::Create
Onyx.get "/users/", Endpoint::User::Index
Onyx.get "/users/:id", Endpoint::User::Get

After:

Onyx::HTTP.on "/users" do |r|
  r.post "/", Endpoint::User::Create
  r.get "/", Endpoint::User::Index
  r.get "/:id", Endpoint::User::Get
end
require "onyx/http/spec"
require "../src/server"

it do
  response = Onyx::HTTP::Spec.get("/")
  response.assert(200, "Hello, Onyx!")
end

See the full changelog at Onyx::HTTP and Onyx releases.

Onyx::SQL changes

The appropriate version is now ~> 0.8.0.

  • Added Onyx::SQL.transaction method to wrap a database transaction (see its API docs):
Onyx::SQL.transaction do
  # Repo uses the transaction connection now
  Onyx::SQL.query(User.where(status: :active))
end
  • Added BulkQuery allowing to insert many models at once (docs):
Onyx::SQL.query(users.insert)

See the full changelog at Onyx::SQL and Onyx releases.

Onyx::EDA changes

The appropriate version is now ~> 0.3.0.

Onyx::EDA got a sweet new release v0.3.0, which is basically an overhaul with many new features, including filtering and awaiting for events. See it in the repo README.