Raxx.Kit - Micro framework for web applications

Raxx.Kit - Micro framework for web applications

From release (0.4.3) install is simplified by using hex.pm.

$ mix archive.install hex raxx_kit
$ mix raxx.kit my_app
...
Get started:

    cd my_app
    iex -S mix

View on http://localhost:8080
View on https://localhost:8443 (uses a self signed certificate)

Project includes

  • Live reloading with ExSync
  • HTTP/2 support (for https endpoint)
  • Static content using Raxx.Static middleware
  • Logging middleware
  • Generated Dockerfile (use --docker)
  • JavaScript bundling with npm (use --node-assets)
  • APIBlueprint routing DSL with Raxx.ApiBlueprint (use --apib)
6 Likes

Hi Peter, couldn’t find this in the docs and I guess many others will be wondering the same, so a few questions for you:

  • How does this differ from Phoenix?
  • When would you recommend people use this instead of Phoenix?
  • Can this be used in multiple layers of an Elixir app, like Phoenix can?
  • What does it have that Phoenix doesn’t?
  • What doesn’t it have that Phoenix does?
  • How does performance compare to Phoenix?
  • Have you got any URLs of sites using this in production?
4 Likes

Hi, Your right maybe it would be helpful to make a few comments about this in the readme. The resources I would point you too are

2 Likes

I think in any case it’s worthwhile to spend ~30 min watching ElixirDaze 2018 - Purify your web development.

  • Raxx is a different abstraction than Plug. Phoenix is built around Plug. From what I’ve seen the Raxx abstraction aligns more closely with the HTTP protocol.
  • Ace is used instead of Cowboy.

From a full stack perspective someone gravitating in front end matters to Vue.js in the “Vue.js vs React” discussion would likely gravitate towards Phoenix - until the Plug abstraction gets in the way.

Raxx seems more for control enthusiasts who don’t mind assembling their own framework in order to have “not a shred of bloat” in their system and prefer an abstraction more closely aligned with HTTP.

I especially liked how the streaming upload looked like a short-lived process handler.

4 Likes

For the moment I wouldn’t disagree with this. However there is no reason an opinionated batteries included framework couldn’t exist on top of Raxx. In exactly the same way phoenix extends plug.

The important thing to me is the abstraction. That is why I have decided to focus on making Raxx rock solid over developing a framework.

1 Like

Automatic code reloading works with JavaScript and CSS 0.4.4

Using the latest update to ExSync any changes to .js or .css files in the project are automatically available of saving the file

1 Like

Fix default ports for tutorial in 0.5.2

Building a distributed chatroom with Raxx.Kit tutorial did not work due to bug with default ports. This latest release fixes that.

4 Likes

Documentation improvements and favicon in 0.5.3

  • Moduledoc added to mix task
  • Explicit link to favicon in template
2 Likes

A bit delayed in response but I will try make some comments

Phoenix is MVC by default. Raxx.Kit makes no assumptions about the model layer. I consider this good practice after reading about hexagonal/onion/clean architecture

If you value referential transparency in your runtime program then try Raxx. If you aren’t sure why functional programmers are so bothered with that then stay with phoenix.
I have found it easier to wrap typespecs around a Raxx program that a Phoenix one because more of the behaviour of the system is exposed through args and return values of a function.

yes

In fact I would recommend just using Raxx documentation directly which explains how to add it to an existing project.

Dialyzer as part of the CI test suite

Presence. Though Phoenix.Presence is a nicely extracted library you can use that with a Raxx project.

:man_shrugging:

2 Likes

Generated projects include Template layer and JavaScript interpolation.

Raxx.Kit 0.5.5 released.

Recent release of Raxx, added the Raxx.View and Raxx.Layout modules.
These are used in generated project and templates include example of interpolating server variables into HTML and JavaScript.

Action Handler

defmodule MyApp.WWW.HomePage do
  use Raxx.Server
  use MyApp.WWW.Layout, arguments: [:title]

  @impl Raxx.Server
  def handle_request(_request = %{method: :GET}, _state) do
    title = "Raxx.Kit"

    response(:ok)
    |> render(title)
  end

  def handle_request(request = %{method: :POST}, _state) do
    case URI.decode_query(request.body) do
      %{"name" => name} ->
        greeting = "Hello, #{name}!"

        response(:ok)
        |> render(greeting)

      _ ->
        response(:bad_request)
        |> render("Bad Request")
    end
  end
end

Template

<main class="centered">
  <section class="accent">
    <h1><%= title %></h1>
    <form action="/" method="post">
      <label>
        <span>tell us your name</span>
        <input type="text" name="name" value="" autofocus>
      </label>
      <button type="submit">Submit</button>
    </form>
    <h2>Find out more</h2>
    <nav>
      <a href="https://github.com/CrowdHailer/raxx">SOURCE CODE</a>
      <a href="https://elixir-lang.slack.com/messages/C56H3TBH8/">CHAT</a>
    </nav>
    <%= javascript_variables title: title %>
    <script type="text/javascript">
      document.addEventListener('DOMContentLoaded', function () {
        app.show(title)
      })
    </script>
  </section>
</main>

p.s. is there any way to get .eex syntax highlighting?

2 Likes

Project generator updated to use Raxx 0.17.0 and Ace 0.18.0.

The latest versions of these projects introduces a separate behaviour for simple servers, Ones where a complete request is transformed to a complete response; and streaming servers.

See the Raxx CHANGELOG for details.

1 Like

SCSS compilation added to node setup and project automatically formatted

0.7.1 released

  • When using the --node-assets flag a watcher is setup to compile but CSS and JavaScript assets
  • Generated projects are automatically formatted upon creation
  • When using the --docker flag and --node-assets the latest node version is installed (11.x)

Generate database setup up using --ecto flag

0.8.0 released

Added

  • Ecto 3.0 boilerplate and postgres service when specifying --ecto flag.
  • Disabling code reloading with --no-exsync flag.
  • Code formatting run after the project is generated.

Changed

  • Compilation artifacts no longer pollute the host machine when using --docker.
  • --docker option uses elixir:1.7.4 as base image.
1 Like

0.9.0 Overhaul of middleware and project structure

From Changelog

  • Use Raxx.Stack for runtime middleware.
  • Move assets and public files into www directory.
  • Clean up child_spec functions for each service.
  • Namespace all action modules under Actions module.
  • Create a separate WWW.Router module.
  • Add an example integration test using :httpc
3 Likes

0.9.2 Fix bug when using docker flag.

This fixes an issue in the generation of the docker-compose.yml file when generated without also choosing the --ecto flag.

Generate API only projects

Release 0.10.0 adds the --api flag for getting started with API only projects. Quick start for api projects is simply.

mix archive.install hex raxx_kit
mix raxx.new --api my_app 

Other features include:

  • Fix projects that use --docker and --node-assets to keep dependencies from being written to host machine.
  • Changing the task from raxx.kit to raxx.new
1 Like

0.10.1 released

Small fixes to the templates that effected the --docker and --node-assets flag.

  • .dockerignore is properly handled as a template.
  • Move .gitignore for node assets to WWW directory.
2 Likes

0.12.0 released

  • Uses latest version of Raxx.View to set up template variables with default values.
  • Default project has Session with flash messages and CSRF protection from Raxx.Session
2 Likes

0.12.1 released

  • Small fix for a bug introduced with Elixir 1.9 where Mix task raxx.new would fail in all cases due to a changed return value for Mix.Generator.create_directory.
4 Likes

0.12.2 released :tada: :exclamation:

  • Changed Update Elixir version in Dockerfile.eex to the newest posible 1.10.2 :ship: :whale:
3 Likes