GithubHelp home page GithubHelp logo

lguzzon-scratchbook / bash-end Goto Github PK

View Code? Open in Web Editor NEW

This project forked from koffiebaard/bash-end

0.0 1.0 0.0 14 KB

Fast, unopinionated, minimalist API framework written solely in Bash.

Home Page: http://bash-end.com

Dockerfile 5.59% Shell 94.41%

bash-end's Introduction

Bash-end

Fast, unopinionated, minimalist API framework written solely in Bash.

curdir="$(dirname "$0")"

source "$curdir/internals.sh"
source "$curdir/controller/comic.sh"

add_route "GET"     /comic/[0-9]+$    "controller_comic_get"
add_route "GET"     /comic            "controller_comic_list"
add_route "POST"    /comic            "controller_comic_create"
add_route "PUT"     /comic/[0-9]+$    "controller_comic_update"
add_route "DELETE"  /comic/[0-9]+$    "controller_comic_delete"

add_404_route                         "default_404"

Features

  • Efficient routing
  • Easily built controllers and models
  • Powerful input validation system
  • Only one dependency; jq
  • Decent test coverage
  • Out of the box MySQL support

Quick Start

The framework itself is just a few bash scripts. You can easily tie it into a webserver using fastcgi.

There is one dependency: jq. So we just install it and get Bash-end from the repo. Like so:

$ git clone https://github.com/koffiebaard/bash-end/
$ apt install jq

If you want to use mysql, you also need mysql-client:

$ apt install mysql-client

Note: there's a config.yaml file in the root, it mostly governs your db connection. An example file:

db_host: localhost                      # host for the database
db_username: supersecret                # username for the database
db_password: alsosecretbutpredictable   # password for the database
basedir: bash-end                       # if the API is under a basedir, list it here

You can run the whole thing with nginx and fcgiwrap, or whichever other flavors you prefer.

Docker

You can also run it with Docker:

$ git clone https://github.com/koffiebaard/bash-end/
$ docker build -t bash-end .
$ docker run --name=bash-end-container -d -p 6969:6969 bash-end

You can now view the API at: http://localhost:6969.

Philosophy

The Bash-end© Philosophy™ extends to all software. Why choose for big complex projects with hundreds of modules, where simple bash scripts more than suffice?

That's just silly.

Replace your ridiculously huge API framework with two or three bash scripts. Do it. Do it now.

Bash-end is simple to use and unopinionated, with a bunch of tools you can use to make your life easier. Or not. It's Bash, so extend it with whatever you want. Sky is the limit! But not even that. Let's get Bash to run on fucking Mars.

Examples

The best example is the API built for the webcomic Consolia.

Tests

To run the tests, simply run test.sh.

$ ./test.sh

Contributing

Feel free to contribute! Ping me or send a pull request and let's go.

License

Bash-end is under the MIT license, but without me shipping the copyright text with the project. That's too much effort.

bash-end's People

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.