Code Monkey home page Code Monkey logo

lapis's Introduction

Lapis

A web framework for Lua/MoonScript supporting OpenResty or http.server

spec

Lapis is production ready, use it on your next huge project.

Learn more on the homepage: http://leafo.net/lapis/

Join Our Community

We just created a Discord for Lapis users and those interested in it to communicate. You can join us here: https://discord.gg/Y75ZXrD

Lapis Powered

Made a website in Lapis? Tell us

Supplemental Libraries

  • lapis-eswidget - A widget base class designed for organizing front-end code bundling
  • lapis-annotate - Autogenerate comments on models with their database schema
  • lapis-console - Interactive MoonScript console for Lapis that runs inside of your browser
  • lapis-exceptions - Exception tracking and reporting
  • lapis-bayes - General purpose Bayes classification for Spam, Fraud, etc.

Running Tests

If you need to run tests outside of our CI. The test suites require Busted and MoonScript. There are three separate test suites:

  • busted -- test Lua implementations
  • busted spec_postgres -- integration tests with PostgreSQL. Requires a running PostgreSQL server
  • busted spec_mysql -- integration tests with MySQL. Requires a running MySQL server
  • busted spec_openresty/ -- integration tests with OpenResty as a server. Requires installation of OpenResty & Databases
  • busted spec_cqueues/ -- integration tests with lua-http and cqueues as a server.

Test suites that require databases need to have the initial database created. A lapis_test database is created on each. You can run each command respectively.

make test_db # postgres test db
make mysql_test_db
  • PostgreSQL: Ensure the postgres user can be logged in with no password.
  • MySQL: Ensure the root user can be logged in with no password.

Using the Docker image

This repository contains a Dockerfile for running the entire test suite. You can run it with the following commands:

docker build -t lapis-test .
docker run lapis-test

docker build will pull in the files in the current directory, including any changes. To test modified code, build again before running the test suite. It should be a quick operation since dependency installation is cached.

lapis's People

Contributors

bjornbytes avatar catesq avatar catwell avatar criztianix avatar dant4z avatar darkwiiplayer avatar daurnimator avatar digitalveer avatar fasterthanlime avatar kidd avatar leafo avatar mabis avatar nathantsoi avatar nbsky avatar neoascetic avatar pygy avatar qaisjp avatar sarquaz avatar seanlai avatar sharpobject avatar shinriyo avatar snatchev avatar starius avatar tangentfoxy avatar tommy-mor avatar torhve avatar turbo avatar usysrc avatar vadi2 avatar winks avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

lapis's Issues

working with postgresql

I'm seeing the following error:

/usr/local/share/lua/5.1/lapis/db/model.lua:329: bad argument #1 to 'unpack' (table expected, got nil)

My development configuration has the following:

postgresql_url "postgres://postgres:[email protected]/my_db"

and in web.moon is:

lapis = require "lapis"
db = require "lapis.nginx.postgres"
import Model from require "lapis.db.model"

class Users extends Model
  @timestamp: true

class App extends lapis.Application
  "/": =>
    user = Users\find 1
    user.email

lapis.serve App

at various times I was also receiving the following message:

found RDS format version 1129268257, but we can only handle version 3

Is there a specific version of openresty i should be using?

Native postgresql driver

There has recently been released a native lua cosocket driver for postgres here:
https://github.com/azurewang/lua-resty-postgres

I did some simple benchmarking ("SELECT 1") and the native driver came out roughly three times as fast for this simple test. I have not done thorough benchmarking.

But maybe the biggest favorable is getting error messages back to the programmer.

Would you consider adding support for this driver?
What about other drivers, lua-resty-mysql, etc, easily doable to abstract out the postgresl-specific parts ?

Remote debugger

The ability for a worker to pause execution and connect to a remote debugger letting you run arbitrary code to inspect the current context.

Move lua.moon to moonscript itself?

Edit: This was sent prematurely, without body...

So: the functionality of lua.moon would benefit all Moonscript libraries that export extendable classes. It would IMO be better off in moonscript/moon/init.moon.

How could I implement per request variables

Right now I have a system like this:

authRequired =
    upload: true
    profile: true


lapis.serve class extends lapis.Application
    @before_filter =>
        dics = i18n.dictionaries
        @cookies.iso = (@GET.iso and dics[@GET.iso]) and @GET.iso or (dics[@cookies.iso] and @cookies.iso or "en")
        @_ = (...) => i18n.text @cookies.iso, ...

        if authRequired[@req.cmd_url\sub(2)] and (not @session.uid) then
            @write redirect_to: @url_for("auth.login") .. "?to=" .. @req.cmd_url

This basically redirects all urls that require authentication to a login page, with its URL sent in a GET variable "to". Is there a feature I can use where I put @authRequired: true somewhere in the upload/profile areas (whether its a subapp or just a regular handle). Where would I access this variable? Is there some sort of inverse for url_for that I could use to achieve this?

config: os.getenv doesn't work

I am trying to understand how the config system works but it's juggling with function environments so it's rather complicated.

One of the results of this is that os.getenv doesn't work in the config context. If you call it in the config file, in a request context, the result will always be nil (even if you call it at the top level of the config file).

This is not a good thing IMO since using the environment to store application configuration is considered a best practice by many.

Postgres Upstream

I'm having some trouble with the the following postgres upstream:

upstream database {
  postgres_server ${{pg POSTGRESQL_URL}};
}

When I run lapis server development I gives me this error:

nginx: [emerg] directive "postgres_server" is not terminated by ";"

upstream database nginx syntax error

worker_processes  ${{NUM_WORKERS}};
error_log stderr notice;
daemon off;

events {
    worker_connections 1024;
}

http {
    include mime.types;
    upstream database {
        postgres_server ${{pg POSTGRESQL_URL}};
    }

    server {
        listen ${{PORT}};
        lua_code_cache ${{CODE_CACHE}};

        location = /query {
            internal;
            postgres_pass database;
            postgres_query $echo_request_body;
        }

        location / {
            default_type text/html;
            content_by_lua_file "web.lua";
        }

        location /static/ {
            alias static/;
        }

        location /favicon.ico {
          alias static/favicon.ico;
        }
    }
}
vagrant@precise32:/vagrant/web$ lapis server
nginx: [emerg] directive "postgres_server" is not terminated by ";" in /vagrant/web/nginx.conf.compiled:13

I did research and its because of the brackets closing the block but I don't know why code cache doesn't do this

struggling with making postgresql work all day

Conversion from moon to lua does not play nice with angular because of the hyphen in ng-model

in moon-script, if I define a new attribute of the input that has hyphen "-", it thinks I'm trying to do arithmetics

input name: "query", "ng-model": "query_str", class: "span9", value: @params.query

the conversion to lua yeilds this:

input({
  name = "query"
}, ng(-{
  model = "query_model",
  class = "span9",
  value = self.params.query
}))

instead of what should be

input({
  name = "query",
  ng-model = "query_model",
  class = "span9",
  value = self.params.query
})

any workaround,

can i modify the function input after it's defined, smth like this...

input name: "query", "ng-model": "query_str", class: "span9", value: @params.query
input["ng-model"] =

this doen't work obviously :-) any easy way other than to modify the moonscript parser?

many thanks

Possible Dependency Issues?

I did a fresh install of Lua, Moonscript and Lapis on a new box running Linux and got errors when I first attempted to run 'lua help'. The first errors were fixed by installing lua-cjson and the second was fixed after I installed the lpeg luarock. This is the current error I get:

moon: /usr/local/share/lua/5.1/lapis/util/encoding.lua:20: module 'crypto' not found:No LuaRocks module found for crypto
no field package.preload['crypto']
no file '/usr/local/share/lua/5.1/crypto.lua'
no file '/usr/local/share/lua/5.1/crypto/init.lua'
no file '/home/rick/.luarocks/share/lua/5.1/crypto.lua'
no file '/home/rick/.luarocks/share/lua/5.1/crypto/init.lua'
no file '/usr/local/share/lua/5.2/crypto.lua'
no file '/usr/local/share/lua/5.2/crypto/init.lua'
no file '/home/rick/.luarocks/share/lua/5.2/crypto.lua'
no file '/home/rick/.luarocks/share/lua/5.2/crypto/init.lua'
no file '/usr/local/share/lua/5.2//crypto.lua'
no file '/usr/local/share/lua/5.2//crypto/init.lua'
no file '/usr/local/share/lua/5.2/crypto.lua'
no file '/usr/local/share/lua/5.2/crypto/init.lua'
no file '/usr/local/lib/lua/5.2/crypto.lua'
no file '/usr/local/lib/lua/5.2/crypto/init.lua'
no file './crypto.lua'
no file '/usr/local/lib/lua/5.1/crypto.so'
no file '/home/rick/.luarocks/lib/lua/5.1/crypto.so'
no file '/usr/local/lib/lua/5.2/crypto.so'
no file '/home/rick/.luarocks/lib/lua/5.2/crypto.so'
no file '/usr/local/lib/lua/5.2/crypto.so'
no file '/usr/local/lib/lua/5.2/loadall.so'
no file './crypto.so'
stack traceback:
[C]: in function 'require'
/usr/local/share/lua/5.1/lapis/util/encoding.lua:20: in main chunk
[C]: in function 'require'
/usr/local/share/lua/5.1/lapis/session.lua:4: in main chunk
[C]: in function 'require'
/usr/local/share/lua/5.1/lapis/application.lua:3: in main chunk
[C]: in function 'require'
/usr/local/share/lua/5.1/lapis/init.lua:2: in main chunk
[C]: in function 'require'
web.moon:1(1): in main chunk

Generators and migrations

As migrations at the moment only work through the server and not the console, it might be a good idea to do the same thing with generators and have them both work thru a Web interface.

We could have a Web interface for designing the schemas for migrations and then running that migration from an out of the box migration route.

I've often wondered why there wasn't a Web interface for those in other frameworks, and the current state of lapis would allow for taking that course.

Those routes would only be available when running as development of course.

And also having those features as Web apps would serve dual purpose as example apps.

Also a setup.lua in which you could give it the pg credentials could be a handy app. (think of it how most php apps have a setup wizard), and in the future lapis add ons could hook into that setup script.

Cheers

Add support for different template renderers

I don't know what other people would want to use, but there could be friendlier integration with other templating libraries.

The current HTML widget system does a lot of work for exposing data and methods from the action as 'helpers' I could expose this API so it's easier to integrate with other renders.

How to run migrations?

i've created a file called migrations/init.lua according to the docs in order to create the migrations table but when I run it with lua migrations/init.lua I get the following error.

lua: /usr/local/share/lua/5.1/lapis/nginx/postgres.lua:135: attempt to index global 'ngx' (a nil value)

Does this mean I must run the migration through the openresty server instead of the command line.

Thanks.

lapis_console crashes on Heroku

When attempting to use lapis_console on Heroku -- for following error is produced:

Error

/app/packages/share/lua/5.1/lapis/application.lua:458: attempt to index field 'req' (a nil value)
Traceback

stack traceback:
    /app/packages/share/lua/5.1/lapis/application.lua:458: in function 'thing'
    /app/packages/share/lua/5.1/lapis/application.lua:212: in function 'write'
    /app/packages/share/lua/5.1/lapis/application.lua:322: in function 'resolve'
    /app/packages/share/lua/5.1/lapis/application.lua:331: in function </app/packages/share/lua/5.1/lapis/application.lua:329>
    [C]: in function 'xpcall'
    /app/packages/share/lua/5.1/lapis/application.lua:329: in function 'dispatch'
    /app/packages/share/lua/5.1/lapis/nginx.lua:170: in function </app/packages/share/lua/5.1/lapis/nginx.lua:168>

Is there an wasy way to setup head...

Found some issues like setup the head in a easy way, without changing the layout.

I'm trying to read the html from an .html archive but when it happens the variables wont work in the other side.

(using LuaHtml)

Not a Issue

Beautiful work!

Saw your screencast, and amazing changes!

what about make a screencast of building a simple example lika a blog?

Enhance Nginx config preprocessor

I have a couple options here:

  • Keep current syntax, add support for things like if statements and functions (parameterized variables)
  • Write a moonscript DSL that outputs Nginx configuration
  • Use an existing templating langauge like Mustache

Ideally it should be easy to enable features. Right now if you want to do something like enable the use of the lapis.nginx.http module you need to copy and paste a chunk of code: http://leafo.net/lapis/reference.html#utilities-making-http-requests It would be nice to avoid that.

Segmentation fault (core dumped) while compiling moon script

Hello,
When I try to compile moon script, I am getting core dump.
I have given the commands I executed, content of the script and later version of installed components and other environment details.

ubuntu@ip-xxxxxx:~/lapis$ cat web.moon
lapis = require "lapis"
lapis.serve class extends lapis.Application
"/": => "Hello World!"

ubuntu@ip-xxxxx:~/lapis$ moonc web.moon
Segmentation fault (core dumped)

ubuntu@ip-xxxx:~/lapis$ moonc -v
MoonScript version 0.2.0

ubuntu@ip-xxxxx:~/lapis$ cat test.moon
export my_func
x = 2323
my_func = (a) -> x + a
print my_func 100

ubuntu@ip-10-29-162-102:~/lapis$ moonc test.moon
Segmentation fault (core dumped)

ubuntu@ip-xxxx:~/downloads$ uname -a
Linux ip-xxx 3.5.0-21-generic #32-Ubuntu SMP Tue Dec 11 18:51:59 UTC 2012 x86_64 x86_64 x86_64 GNU/Linux

ngx_openresty-1.2.8.1
MoonScript version 0.2.0
Lapis 0.0.1

/opt/openresty/luajit/lib/luarocks/rocks/ansicolors/1.0.2-3/ansicolors-1.0.2-3.rockspec
/opt/openresty/luajit/lib/luarocks/rocks/copas/1.1.6-1/copas-1.1.6-1.rockspec
/opt/openresty/luajit/lib/luarocks/rocks/coxpcall/1.13.0-1/coxpcall-1.13.0-1.rockspec
/opt/openresty/luajit/lib/luarocks/rocks/lapis/dev-1/lapis-dev-1.rockspec
/opt/openresty/luajit/lib/luarocks/rocks/lpeg/0.11-2/lpeg-0.11-2.rockspec
/opt/openresty/luajit/lib/luarocks/rocks/lua-cjson/2.1.0-1/lua-cjson-2.1.0-1.rockspec
/opt/openresty/luajit/lib/luarocks/rocks/lua-ev/v1.3-1/lua-ev-v1.3-1.rockspec
/opt/openresty/luajit/lib/luarocks/rocks/lua-llthreads/1.2-1/lua-llthreads-1.2-1.rockspec
/opt/openresty/luajit/lib/luarocks/rocks/luasocket/2.0.2-5/luasocket-2.0.2-5.rockspec
/opt/openresty/luajit/lib/luarocks/rocks/luaxml/101012-1/luaxml-101012-1.rockspec
/opt/openresty/luajit/lib/luarocks/rocks/md5/1.1.2-2/md5-1.1.2-2.rockspec

ubuntu@ip-xxxxx:~/downloads$ echo $PATH
/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/opt/openresty/nginx/sbin:/opt/openresty/luajit/bin

ubuntu@ip-xxxx:~/downloads$ echo $LUA_PATH
./?.lua;/opt/openresty/luajit/lib/?.lua;/opt/openresty/luajit/lib/?/?.lua;/opt/openresty/luajit/share/lua/5.1/?.lua;/opt/openresty/luajit/share/lua/5.1/?/init.lua;/opt/openresty/luajit/share/luajit-2.0.1/jit/?.lua;/opt/openresty/luajit/share/lua/5.1/?/?.lua

ubuntu@ip-xxxxx:~/downloads$ echo $LUA_CPATH
./?.so;/opt/openresty/luajit/lib/?.so;/opt/openresty/lualib/?.so;/opt/openresty/luajit/lib/lua/5.1/?.so;/opt/openresty/lualib/?/?.so;/opt/zeromq/lib/?.so;

Lua 5.2 & luasocket

Is Lapis compatible with Lua 5.2? I have been unsuccessful in installing Lapis on systems using Lua 5.2 (OSX 10.8 & Ubuntu 12.04) due to the luasocket dependency. It seems that this is a common issue with luasockets and 5.2 but after many hours I still have not found a solution. I've tried installing using "luarocks install luasocket" and methods mentioned here http://lua-users.org/lists/lua-l/2013-06/msg00311.html and building from source. Below are the errors that I'm getting:

Using http://www.luarocks.org/repositories/rocks/luasocket-2.0.2-4.src.rock... switching to 'build' mode
Archive: /tmp/luarocks_luarocks-rock-luasocket-2.0.2-4-8002/luasocket-2.0.2-4.src.rock
inflating: luasocket-2.0.2-4.rockspec
inflating: luasocket-2.0.2.tar.gz
cd src; make all
make[1]: Entering directory `/tmp/luarocks_luasocket-2.0.2-4-3460/luasocket-2.0.2/src'
gcc -O2 -fPIC -DLUASOCKET_DEBUG -I/usr/local/include -c -o luasocket.o luasocket.c
In file included from luasocket.c:31:0:
auxiliar.h:38:61: error: unknown type name ‘luaL_reg’
luasocket.c:50:1: error: unknown type name ‘luaL_reg’
....

I'm new to Lua and I think it may be possible to install luasockets under 5.2 by compiling Lua with the LUA_COMPAT_MODULE flag, but I'm not sure how to do this.

I'd appreciate any help in getting this working under Lua 5.2.
Thanks!

Issues with sessions

Hello,

I used Lapis over the weekend, congats on the progress!

I think I found two little bugs with sessions, both in the write_session function.

__index can be a function

I did not have enough time to find out why that happens but __index in the session metatable can be a function, so when write_session tries to iterate it assuming that it is a table it breaks.

Removing the last key-value pair fails

When you write the session you start by checking that it is not empty. The problem is that maybe it is empty now but it was not empty earlier. If the session is empty you should make sure it is removed on the client side.

This is easy to find out if you make a simple project with two routes, one to login which sets the current user like in the docs:

@session.current_user = "leaf"

and the other one to logout which removes it:

@session.current_user = nil

This will not work if there is nothing else in the session (logout is impossible). A possible workaround in current state is replacing the logout code with one of those:

@session.current_user = false

or

@session._dummy = true
@session.current_user = nil

config values not respecting environment for mac

my config is

config 'production'
  code_cache 'on'

if I do

lapis server production

with the following in my web.moon

config = require ('lapis.config').get!

lapis.server class extends lapis.Appllication

@html ->
 raw config._name..' '..config.code_cache

The output is "development off"

This appears to only happen on my mac, on the server production settings appear just fine. My nginx.conf gets compiled correctly.

Cookies cannot be set.

I'm trying to set some cookies in Lapis 0.0.5 but the Set-Cookie is not being included in the output.

@cookies.foo = "bar"

I seem to be able to read cookies from incoming requests though.

Questions about HTML Generation

Hi!
Lapis is wery cool!
I have two questions about html generator. I think they are dummy, im new in lua & moonscript, sorry.

How can i add custom html5 tags in to element? Something like 'data-target', i try to do data-target: 'target_element' and "data-target": "target_element" - and its crash on compile.
How can i loop and print array in view? Not found this item in the manual instructions.
Tha

Blog tutorial

Write a tutorial creating a blog using Lapis and Postgres.

Should cover:

  • Setting up project
  • Working with models
  • Creating migrations
  • Doing CSRF protection
  • [maybe] Create user authentication system

User "recreation"

So say I store my user.id in @session.id and the guy refreshes the page. I'd naturally want to get my Users class instance user back but how would I do this without having to use Users\find id:@session.id on every page load? I can't store my user in @session.user because it's serialised to json.

I was talking about this on IRC and I had the idea of storing my user instances in a table and if it is unused for a certain amount of time it is purged. I was just wondering if there is a user management system built in lapis that hasn't been documented yet, and if not, what method do you recommend? What does itch.io do?

Convert schema to a MoonScript file

A command that takes the current state of the database and dumps the schema as a MoonScript file. Same idea as schema.rb in Rails.

This is useful for getting a new database up and running for different machines or for test environments.

Unable to update NULL to database column

When trying to update a model with null value, it will be ignored in the UPDATE sql statement.

If passing a table like this:

assert_error my_model\update{my_column: nil}

I get a weird error about module "view.x" not found

Is there a way to update a column with null value?

Can't install (Xubuntu)

Failure → /usr/local/share/lua/5.1/busted/core.lua @ 59
Failed executing testfile; ./spec/util_spec.moon
/usr/local/share/lua/5.1/busted/core.lua:60: ./spec/util_spec.moon: Failed to parse:
[106] >> "http://localhost.com:8080/test?dad=days#cool_thing"

Failure → /usr/local/share/lua/5.1/busted/core.lua @ 59
Failed executing testfile; ./spec/postgres_spec.moon
/usr/local/share/lua/5.1/busted/core.lua:60: [string "./lapis/nginx/postgres.moon"]:19: module 'rds.parser' not found:
no field package.preload['rds.parser']
no file './src/rds/parser.lua'
no file './src/rds/parser/rds/parser.lua'
no file './src/rds/parser/init.lua'
no file './rds/parser.lua'
no file '/usr/local/share/lua/5.1/rds/parser.lua'
no file '/usr/local/share/lua/5.1/rds/parser/init.lua'
no file '/usr/local/lib/lua/5.1/rds/parser.lua'
no file '/usr/local/lib/lua/5.1/rds/parser/init.lua'
no file '/usr/share/lua/5.1/rds/parser.lua'
no file '/usr/share/lua/5.1/rds/parser/init.lua'
no file './csrc/rds/parser.so'
no file './csrc/rds/parser/rds/parser.so'
no file './rds/parser.so'
no file '/usr/local/lib/lua/5.1/rds/parser.so'
no file '/usr/lib/x86_64-linux-gnu/lua/5.1/rds/parser.so'
no file '/usr/lib/lua/5.1/rds/parser.so'
no file '/usr/local/lib/lua/5.1/loadall.so'
no file './csrc/rds.so'
no file './csrc/rds/rds.so'
no file './rds.so'
no file '/usr/local/lib/lua/5.1/rds.so'
no file '/usr/lib/x86_64-linux-gnu/lua/5.1/rds.so'
no file '/usr/lib/lua/5.1/rds.so'
no file '/usr/local/lib/lua/5.1/loadall.so'

make: ** [test] Erro 2

Link to css/js files in HTML

How to insert link to css / js files in html header ?
could you please add lapis project example ? like simple blog, rest api etc.

Thanks.

tup monitor not working

When i call tup upd it works, but when i call tup monitor -a i dont even get any feedback. Do you know how to solve it? (Ubuntu)

Use lua-resty-postgres for Postgres backend

https://github.com/azurewang/lua-resty-postgres

I actually already implemented this but there were some issues. Only one authentication method is implemented, and types aren't coerced correctly (true is returned as "true").

If I integrated this I would have to find solutions for those problems and push them upsteam.

The biggest advantage of this is that you can make queries in places where subrequests aren't possible, also we can get errors for queries application side hopefully.

Using Heroku with config.moon?

I've built up a small config.moon based on the examples in the reference manual. If I use heroku-openresty -- it seems to have a preference for using environment variables instead of config.moon.

Additionally, it seems that a lapis app requires launching via lapis server production instead of start_nginx.sh.

Using Heroku with Lapis seems to be endorsed in the docs (of both Lapis and heroku-openresty) -- but there are no docs on how to do so.

What is the correct way to configure and launch a Lapis app on Heroku?

Support MySQL

Add MySQL as a backend for the models and query helpers.

  • lapis.db.mysql query functions
  • lapis.db.mysql.schema schema functions
  • lua-resty-mysql backend for server
  • support for models
  • query parser for pagination
  • documentation
  • integration specs that hit server

Performance vs OpenResty

Hi,

First, great work. I am fishing around a high performance web framework for my next API-only project. Simple, the backend will spit out json queried from some data store. I did some simple benchmarking for the simplest case, outputting json by encoding an object. mainly:

"/": => json: {message: "Hello, World!"}

On my machine, OpenResty is averaging around 5000 reqs/s, while Lapis is around 2900 reqs/s (and for comparison, an equivalent nodejs express app is around 2200 reqs/s)

How you ever benchmarked Lapis? Are these numbers on par with your experience?

sha2 library fails for some reason

sudo luarocks install sha2
The sha2 library works perfectly well in the Lua console

> require"sha2"
> print(sha2.sha512hex("tet"))
c28ca33f1069c6adaa16d0f056e3d7d9039f58584ee4ac424b465279c1f4cf3f37ea23ce372710ad8163aca0506d06b9784f3bb91d6d866e48737b7e5dbde961
>  

but when trying it in lapis. after doing screen -r lapis I typed lapis server and the regular lapis information shows up (including lua_cache stuff) those stuff disappeared.

vagrant@precise32:/vagrant/web$ screen -dmS lapis
vagrant@precise32:/vagrant/web$ screen -r lapis

b6b3b000-b6b5b000 rw-p 00000000 00:00 0 
b6b5b000-b6b64000 r-xp 00000000 fc:00 2234938    /usr/local/lib/lua/5.1/lpeg.so
b6b64000-b6b65000 r--p 00008000 fc:00 2234938    /usr/local/lib/lua/5.1/lpeg.so
b6b65000-b6b66000 rw-p 00009000 fc:00 2234938    /usr/local/lib/lua/5.1/lpeg.so
b6b66000-b6b6b000 r-xp 00000000 fc:00 2234678    /usr/local/openresty/lualib/cjson.so
b6b6b000-b6b6c000 ---p 00005000 fc:00 2234678    /usr/local/openresty/lualib/cjson.so
b6b6c000-b6b6d000 r--p 00005000 fc:00 2234678    /usr/local/openresty/lualib/cjson.so
b6b6d000-b6b6e000 rw-p 00006000 fc:00 2234678    /usr/local/openresty/lualib/cjson.so
b6b6e000-b6b8e000 rw-p 00000000 00:00 0 
b6b8e000-b6bb2000 rw-p 00000000 00:00 0 
b6bb2000-b6c54000 r-xp 00000000 fc:00 1840134    /usr/lib/i386-linux-gnu/libsqlite3.so.0.8.6
b6c54000-b6c55000 r--p 000a2000 fc:00 1840134    /usr/lib/i386-linux-gnu/libsqlite3.so.0.8.6
b6c55000-b6c56000 rw-p 000a3000 fc:00 1840134    /usr/lib/i386-linux-gnu/libsqlite3.so.0.8.6
b6c56000-b6c57000 rw-p 00000000 00:00 0 
b6c57000-b6c9a000 r-xp 00000000 fc:00 1843382    /usr/lib/i386-linux-gnu/libhx509.so.5.0.0
b6c9a000-b6c9b000 ---p 00043000 fc:00 1843382    /usr/lib/i386-linux-gnu/libhx509.so.5.0.0
b6c9b000-b6c9c000 r--p 00043000 fc:00 1843382    /usr/lib/i386-linux-gnu/libhx509.so.5.0.0
b6c9c000-b6c9e000 rw-p 00044000 fc:00 1843382    /usr/lib/i386-linux-gnu/libhx509.so.5.0.0
b6c9e000-b6cab000 r-xp 00000000 fc:00 1843376    /usr/lib/i386-linux-gnu/libheimbase.so.1.0.0
b6cab000-b6cac000 r--p 0000c000 fc:00 1843376    /usr/lib/i386-linux-gnu/libheimbase.so.1.0.0
b6cac000-b6cad000 rw-p 0000d000 fc:00 1843376    /usr/lib/i386-linux-gnu/libheimbase.so.1.0.0
b6cad000-b6cd4000 r-xp 00000000 fc:00 1843379    /usr/lib/i386-linux-gnu/libwind.so.0.0.0
b6cd4000-b6cd5000 r--p 00027000 fc:00 1843379    /usr/lib/i386-linux-gnu/libwind.so.0.0.0
b6cd5000-b6cd6000 rw-p 00028000 fc:00 1843379    /usr/lib/i386-linux-gnu/libwind.so.0.0.0
b6cd6000-b6cd9000 r-xp 00000000 fc:00 2883894    /lib/i386-linux-gnu/libgpg-error.so.0.8.0
b6cd9000-b6cda000 r--p 00002000 fc:00 2883894    /lib/i386-linux-gnu/libgpg-error.so.0.8.0
b6cda000-b6cdb000 rw-p 00003000 fc:00 2883894    /lib/i386-linux-gnu/libgpg-error.so.0.8.0
b6cdb000-b6cdc000 rw-p 00000000 00:00 0 
b6cdc000-b6cec000 r-xp 00000000 fc:00 1843351    /usr/lib/i386-linux-gnu/libp11-kit.so.0.0.0
b6cec000-b6ced000 r--p 0000f000 fc:00 1843351    /usr/lib/i386-linux-gnu/libp11-kit.so.0.0.0
b6ced000-b6cee000 rw-p 00010000 fc:00 1843351    /usr/lib/i386-linux-gnu/libp11-kit.so.0.0.0
b6cee000-b6cfe000 r-xp 00000000 fc:00 1843353    /usr/lib/i386-linux-gnu/libtasn1.so.3.1.12
b6cfe000-b6cff000 r--p 0000f000 fc:00 1843353    /usr/lib/i386-linux-gnu/libtasn1.so.3.1.12
b6cff000-b6d00000 rw-p 00010000 fc:00 1843353    /usr/lib/i386-linux-gnu/libtasn1.so.3.1.12
b6d00000-b6d14000 r-xp 00000000 fc:00 1843345    /usr/lib/i386-linux-gnu/libroken.so.18.1.0
b6d14000-b6d15000 r--p 00013000 fc:00 1843345    /usr/lib/i386-linux-gnu/libroken.so.18.1.0
b6d15000-b6d16000 rw-p 00014000 fc:00 1843345    /usr/lib/i386-linux-gnu/libroken.so.18.1.0
b6d16000-b6d48000 r-xp 00000000 fc:00 1843373    /usr/lib/i386-linux-gnu/libhcrypto.so.4.1.0
b6d48000-b6d49000 r--p 00032000 fc:00 1843373    /usr/lib/i386-linux-gnu/libhcrypto.so.4.1.0
b6d49000-b6d4a000 rw-p 00033000 fc:00 1843373    /usr/lib/i386-linux-gnu/libhcrypto.so.4.1.0
b6d4a000-b6d4b000 rw-p 00000000 00:00 0 
b6d4b000-b6deb000 r-xp 00000000 fc:00 1843348    /usr/lib/i386-linux-gnu/libasn1.so.8.0.0
b6deb000-b6dec000 ---p 000a0000 fc:00 1843348    /usr/lib/i386-linux-gnu/libasn1.so.8.0.0
b6dec000-b6ded000 r--p 000a0000 fc:00 1843348    /usr/lib/i386-linux-gnu/libasn1.so.8.0.0
b6ded000-b6df0000 rw-p 000a1000 fc:00 1843348    /usr/lib/i386-linux-gnu/libasn1.so.8.0.0
b6df0000-b6df1000 rw-p 00000000 00:00 0 
b6df1000-b6e70000 r-xp 00000000 fc:00 1843385    /usr/lib/i386-linux-gnu/libkrb5.so.26.0.0
b6e70000-b6e72000 r--p 0007e000 fc:00 1843385    /usr/lib/i386-linux-gnu/libkrb5.so.26.0.0
b6e72000-b6e74000 rw-p 00080000 fc:00 1843385    /usr/lib/i386-linux-gnu/libkrb5.so.26.0.0
b6e74000-b6e7a000 r-xp 00000000 fc:00 1843388    /usr/lib/i386-linux-gnu/libheimntlm.so.0.1.0
b6e7a000-b6e7b000 r--p 00005000 fc:00 1843388    /usr/lib/i386-linux-gnu/libheimntlm.so.0.1.0
b6e7b000-b6e7c000 rw-p 00006000 fc:00 1843388    /usr/lib/i386-linux-gnu/libheimntlm.so.0.1.0
b6e7c000-b6efe000 r-xp 00000000 fc:00 2883896    /lib/i386-linux-gnu/libgcrypt.so.11.7.02013/10/30 11:39:32 [notice] 4020#0: signal 17 (SIGCHLD) received
2013/10/30 11:39:32 [alert] 4020#0: worker process 4021 exited on signal 6
2013/10/30 11:39:32 [notice] 4020#0: start worker process 4022

I can then CTRL+C out of there and proceed to leave my screen.

Returning javascript -- unsescaped?

I have a lapis endpoint that returns some dynamically generated javascript. I've noticed that quotes and some other symbols are being escaped by lapis. How can I prevent lapis from escaping output?

Is there the how to upload media files?

Hi there.

I' like to upload media file via the lapis server.
But, I searched "media" word the repository, and googled.
However, I couldn't fined how to.
Is it impossible?

Amazing job.

Your framework and its documentation are remarkable (I just spent an hour and a half browsing the docs). So is Moonscript.

That's obviously not an issue :-), but I didn't know where else to post this...

Keep it up!

js and css links are concatenated

hi i was playing around and noticed that generated lines for css and js got all concatenated ie: <link rel="stylesheet"href="/static/style.css"/> witch is only annoying.
A quick fix: buffer:write(k, "=", '"', escape(tostring(v)), '" ')
It looks like the padding part doesn't work properly

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.