GithubHelp home page GithubHelp logo

aquelarre's Introduction

aquelarre Generic badge made-with-python made-with-bash License: MIT

Aquelarre

Aquelarre is a DSL for making minimalistic web apps using scripts.

#!/usr/local/bin/aquelarre
is_weekend = scripts/is_weekend.sh 

get / : 
     is_weekend => {"get": "drunk"}, 200
     not is_weekend => {"don't":" get drunk"}, 400
end

Concept

Usually when developing web apps the common frameworks include everything you need, like serializers, ORM, etc. the cost
of this is having some extra boilerplate code and perhaps a learning curve. Also, you have to stick to the one language that the framework was written.
With aquelarre you write a script and redirect the URLs to another scripts of any language, so you can work with a lot of different libs. You decide how to serialize data and how to store it in a database, it could be just plain .txt, .cvs, .json, a relational db or whatever you want.

It's more minimalistic than similiar software beacuse:

  • Only implements: GET, POST, PUT, PATCH and DELETE HTTP methods.
  • Each request is proccesed by a custom script (of any language), it's parameters are passed as script parameters and it's body JSON payload as stdin.
  • Responses are in JSON format only, must be the stdout of a script.

Installing

  1. Clone the repo and go to it:
$ git clone https://github.com/domandlj/aquelarre.git 
$ cd aquelarre
  1. Run the installer (only works with Mac OS, Linux and Termux.).
$ chmod +x install.sh
$ sudo ./install.sh
  1. And that's it, you can now run your own aquelare .re scripts like
$ aquelarre script.re

or

$ ./script.re

the Aquelarre prompt will be started:

> ๐Ÿ Aquelarre server started http://localhost:8080

and you can now remove the github repo if you want.

  1. You can run again the install script to remove Aquelarre.

Syntax example

script.re

#!/usr/local/bin/aquelarre

exists_worker = scripts/exists_worker.py
get_worker = scripts/get_worker.py
anything = scripts/anything.sh
create_worker = scripts/create_worker.py

get / : 
     anything => home, 200 
end

get /?id&name :
    # succes.
        exists_worker => get_worker, 201 
    # failure.
	not exists_worker => {"error msg:", "worker does not exist"}, 400
end

post / : 
	not exists_worker => create_worker, 201
end

Now you can execute the script with aquelarre interpreter, like: $ aquelarre script.re Or running it like an script, but first you give it permissions:

$ chmod +x script.re  
$ ./script.re  

When the client makes an HTTP request to an URL, the parameters and arguments must be in a query style:
/resource?parameter1=value1&parameter2=value2
Other ways like this:
/resource/value1
are not allowed.

Implementation.

The server is implemented with httt.server Python lib which isn't recommended for production, so one of this days i'm going to implement it with some WSGI compatible server. Also there are no tests yet.

License

MIT License (ยฉ 2021 Juan Salvador Domandl).

aquelarre's People

Contributors

domandlj avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

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.