Why we chose openresty, lua, lapis & arangodb ?

Why ArangoDB?

I'm working with ArangoDB since 2 years now. I was looking for a strong noSQL database with a great performances with joins feature. After some project within mongoDB I decided to migrate to ArangoDB for several reasons.

  • A Nice AQL language
  • Joins
  • Transactions
  • Multi Documents (document, graphs, key/value)
  • Foxx (embed your logic in the heart of the database)
Performances are very good and using Foxx is very easy and powerful.

Why Openresty?

I discovered Openresty two years ago during tech talk in Hong Kong. The developer was so enthousiast ... and he was a Ruby developer just like me. It took me 1 year to finaly take times to play with it...

Openresty is a fork of Nginx including Lua. Lua is a small but robust language.

It use Lua co-routines so the code is not blocking. You keep writing your code like a procedural code... It will help you to keep a code easy to read and maintain.

Here a sample using moonscript language (which compile into plain lua code)

http = require "lapis.nginx.http"

class extends lapis.Application
  "/": =>
    -- a simple GET request
    body, status_code, headers = http.simple "http://leafo.net"

    -- a post request, data table is form encoded and content-type is set to
    -- application/x-www-form-urlencoded
    http.simple "http://leafo.net/", {
      name: "leafo"
    }

    -- manual invocation of the above request
    http.simple {
      url: "http://leafo.net"
      method: "POST"
      headers: {
        "content-type": "application/x-www-form-urlencoded"
      }
      body: {
        name: "leafo"
      }
    }

Why Lapis?

Openresty world is finaly not that big. The only decent framework I found was Lapis (maybe not the only one -- but website and documentation was very clear).

It's very very fast and comes with some utilities. Of course we are far away from a Ruby on Rails framework but it's complete enough to build applications.


The whole stack

I worked on a project called foxxy. It was a RiotJS app for building CRUDs quickly for ArangoDB. I kept the same tool and added a Lapis app as frontend. Fasty was borned. Fasty is fast and easy to work with. I'll write some tutorials about how to create dynamic content, how to deal with a Foxx Restful API...

Leave a comment