Package: apijet
⚙A command line tool to deploy python Rest APIS in 20 secs.⚙🔗 Example of a backend for a TODO appApijet is a Python framework for building APIs via the command line. Apijet is a useful framework for fast prototyping Rest APIs. Apijet will deploy python code according to the well-defined pattern(see here), you only have to pay attention to the business logic and to the database queries.You will be able to deploy endpoints following these 5 steps:Install apijetOnce you have installed the package,apijetwill be available as bash command.$> pip install apijetCreate a projectThecreatecommand generates the skeleton of the project and the main project files.$> apijet create --name myProject --port 9090 --address 127.0.0.1
$> cd my_projetAdd and endpoint.The endpoint can also need database support, in this case, you pass the--databaseparameter and Apijet will generate the code forCRUDbasic operation for the endpoint. If you need database support, you make sure thatmongodbis running. Consider a Docker container to deploy an instance in a short time(see here).$> apijet endpoint --name myEndpointRun the server$> python -m myProject.appOpen your browserThe APIs will be exposed according the automatic interactive API documentation bySwagger.
Open your browser @http://127.0.0.1:9090/docsto test out your work!These steps generate a follow folder and file structure:.
|-- myProject
|   |-- core
|   |   |
|   |   `-- myendpoint.py
|   |-- database
|   |   |-- dbmanager.py
|   |   |-- message.py
|   |   |-- myendpoint.py
|   |   `-- pyobjectid.py
|   |-- models
|   |   |
|   |   `-- myendpoint.py
|   |-- routers
|   |   |
|   |   `-- myendpoint.py
|   `-- app.py
`-- apijet.jsonThe project configuration is saved in theapijet.jsonfile:{"name":"myProject","port":1234,"address":"127.0.0.1","workers":1,"mongo":{"auth":false,"address":"127.0.0.1","port":27017,"username":"","password":""},"endpoints":["myEndpoint"]}where:addressandportare used by the web server.ifworkers> 1,Gunicornwill be started otherwiseUnicornas ASGI web serverifmongo.authis true,mongo.usernameandmongo.passwordare requestedRun MongoDB in a docker contaienrIf you are a fan of docker and you want to run an instance of MongoDb without stress:$> docker run -d -p 27017:27017 --name myProject-db mongo:latestSource code and pattern.Apijet project folder contains the auto-generated python code. The code is arranged in four folders: core, repository, router and models. When a new endpoint is added, a new file in each of these four folders is created. These four files have the same name (/myEndpoint.py) of the endpoint but they have different behaviour, see the following pattern.RouterFiles created as routers expose the endpoints, they receive the user request and send back the response. (i.e. router/myEndpoint.py)CoreFiles as core implement the business logic. Your algorithms and data processing stuff go here. (i.e. core/myEndpoint.py)RepositoryFiles as repositories make the interaction with the database. Your queries go here. (i.e. repository/myEndpoint.py)ModelsFor each endpoint, core, repository, and router communicate through the data structure. The data structure is located in the folder models. You modify this file with the parameters you need to handle in your project.🔗 Follow this link for the example on how to implement a backend for a TODO appExpose an endpoint in 20 secs.Dev-StackThe code is generated exploiting the following development stack :MongoDB: Document database -🔗Pymongo: Python library for working with MongoDB -🔗apijet: RestApi framework -🔗Pydantic: Python data validator & more -🔗Uvicorn: ASGI web server implementation for Python -🔗CLI CommandsHelper$> apijet -h
usage: apijet [-h] {create,endpoint,remove} ...

apijet - Api Generator v: 0.2.2

optional arguments:
  -h, --help            show this help message and exit

Actions:
  {create,endpoint,remove}
    create              Create a new project
    endpoint            Add or Remove an endpointto the project
    remove              Remove a projectCreate projet$> apijet create -h
usage: apijet create [-h] [--port PORT] [--name NAME] [--address ADDRESS]

optional arguments:
  -h, --help         show this help message and exit
  --port PORT        port where apis are exposed
  --name NAME        project name
  --address ADDRESS  ip address where apis are exposedAdd endpoint$> apijet endpoint -h
usage: apijet endpoint [-h] [--add ADD] [--database] [--remove REMOVE]

optional arguments:
  -h, --help       show this help message and exit
  --add ADD        endpoint name
  --database       say that the endpoint needs database support
  --remove REMOVE  endpoint name