LaQuay / API-Out-of-the-box

Run your API out of the box, and consume it, simple, fast and easy.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

API-Out-of-the-box

Run your API out of the box, and consume it, simple, fast and easy.

Have you ever wanted to perform a proof of concept in which you needed backend software and frontend software? Or, have you ever seen the need to start a project but did not know where?

In this repository you will find code and information on how to start from almost-zero a project that has a backend, frontend, and an Android application!

What includes

Backend

  • Alpine 3.9
  • Python 3.7.2
  • Flask 1.0.2

Database

  • Alpine
  • Postgres 11.2
  • pgAdmin4.3

Frontend

  • Alpine
  • React 16.8
  • Node 8.15

Android application

Based in Android API 28 and with SDK minimum of API 19. It has Volley ready to be used, to call APIs.

Requirements

The software is meant to be run with Docker.

And, for the Android App, you need an IDE (e.g. Android Studio) and an Android Device.

Setup

Backend

Add your frontend URL in backend/source/resources_loader.py

Frontend

Add your backend URL in frontend/src/config.js

Run the project!

Run separately.

  • make setup
  • make run-backend
  • make run-frontend

And you will have running in:

  • PORT 3000: React - Frontend
  • PORT 5000: Flask REST API - Backend
  • PORT 5432: PostgresDB
  • PORT 5433: pgAdmin 4

Connect to pgAdmin 4

Open localhost:5433. The user and password are the ones that are shown in the docker-compose.yml.

To connect to the postgres database. Click in Add New Server and add the following information in the Connection tab:

Host name/address: postgres
Port: 5432
Maintenance database: postgres
Username: postgres
Role:
Service:

Default API call to the backend

POST :5000/entries/
Content-Type: application/json
{
    "value": "sample",
    "date": "2019-04-23 16:10:45"
}

And the response will be:

{
    "data": {
        "internal_id": 1
    },
    "error": null
}

Troubleshooting

Make run failed

Make sure the user has permission to run run.sh and that this file is in LF format.

docker run '...'
docker: Error response from daemon: OCI runtime create failed: container_linux.go:348: starting container process caused "exec: \"run.sh\": executable file not found in $PATH": unknown.
Makefile:27: recipe for target 'run-backend' failed
make: *** [run-backend] Error 127

Illegal option '-' in .sh

Make sure the user has permission to run configure-postgres.sh and that this file is in LF format.

About

Run your API out of the box, and consume it, simple, fast and easy.

License:MIT License


Languages

Language:JavaScript 33.3%Language:Java 30.9%Language:Python 23.4%Language:HTML 5.3%Language:Makefile 3.1%Language:Dockerfile 2.0%Language:Shell 1.5%Language:CSS 0.5%