Skip to content
Web framework for the serverless world.
Branch: master
Clone or download
pdiazvargas feature/update-readme (#19)
* Minor updates to keep the readme in sync with the documentation

* Minor doc updates
Latest commit f26f170 Mar 22, 2019
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
.circleci
assets
docs
examples/events feature/sphinx-setup (#12) Feb 25, 2019
minik feature/doc-updates (#17) Mar 17, 2019
requirements
scripts feature/init-setup (#1) Jan 28, 2019
tests feature/issue-11-routing-issue (#14) Feb 25, 2019
.coveragerc feature/init-setup (#1) Jan 28, 2019
.gitignore
AUTHORS
CHANGES.rst feature/doc-updates (#17) Mar 17, 2019
CONTRIBUTING.rst feature/sphinx-setup (#12) Feb 25, 2019
LICENSE Adding manifest to include static resources in deployment. Updating d… Feb 1, 2019
MANIFEST.in
Makefile feature/doc-updates (#17) Mar 17, 2019
README.rst
requirements.txt
setup.cfg Initial take! Jan 28, 2019
setup.py feature/sphinx-setup (#12) Feb 25, 2019

README.rst

Minik: Serverless Web Framework

assets/minik.png

circle pypi version apache license

Using AWS lambda functions and API Gateway, minik will serve as the framework that facilitates development in the serverless space.

Installing

Install the latest release:

>>> pip install minik
✨🍰✨

Only Python 3.6+ is supported.

Simple Example

In it's most basic form; quite honestly, it's only form. This is how your lambda function should look like:

from minik.core import Minik, BadRequestError

app = Minik()

@app.route('/hello/{name}')
def hello_view(name):

    if name == 'FINDME':
        # Returns a 400 status code with the message as the body.
        raise BadRequestError(msg='This is not a supported name.')

    # A simple way of getting the current request as json.
    request_payload = app.request.json_body
    return {'hello': name}

HTTP Methods

With minik you can also specify the HTTP methods for a given view. If you don't define the methods, by default, every single HTTP method will be allowed.

from minik.core import Minik

app = Minik()

@app.route('/events/{location}')
def events_view(location):
    # This route will be invoked for GET, POST, PUT, DELETE...
    return {'data': ['granfondo MD', 'Silver Spring Century']}

@app.route('/events', methods=['POST', 'PUT'])
def create_event_view():
    create_event(app.request.json_body)
    return {'result': 'complete'}

Motivation

The team behind this framework is adopting a very minimal set of features to enhance and streamline web development in the serverless space. These were the business needs that encouraged us to build minik:

  • I need to have the ability to write an API using a syntax I'm familiar with (flask like) in the AWS ecosystem.
  • I want to decide how to build and deploy my lambda functions. I do not want my framework to dictate these processes for me. I want to own them!
  • When installing my framework, I want to get only the framework. I don’t want to any additional tooling or any additional process-based workflows..
  • When using the microframework I am responsible for the configuration required to associate my lambda function to its endpoints.

The features of this library should be absolutely driven by a very specific business need. So far, the minimal approach has been sufficient for our team to write and expose an API using AWS services.

Just the framework

Things to be aware of when working using minik:

  • When used in your lambda function, you're responsible of including the source code of minik in your .zip artifact. For packaging purposes we recommend using Juniper.
  • Unlike other frameworks like Flask or Django where using the decorator is sufficient to define the routes of the web app. In minik, you're responsible for linking a lambda function to a the API gateway. We recommend using a SAM template.
  • Minik does not include a local development server! For testing purposes, you can either deploy your lambda to AWS using sam package and sam deploy. For local deployment purposes you can use sam local.

Quickstart

Minik is just one of the pieces that you need to build serverless APIs. If you are curious to learn more about best practices and how to get started with this microframework, checkout out getting started guide.

The quickstart uses a very simple example, which is included in this codebase, as a way to highlight the benefits of the framework.

Contributing

For guidance on setting up a development environment and how to make a contribution to Minik, see the contributing guidelines.

Links

You can’t perform that action at this time.