ghomem / overloop-101

0 stars 0 forks source link

Overloop Tech Test Backend

Running with Docker

Running with a virtual environment

Running with Puppet + is_puppet_base

node 'overloop-demo' {

    # common baseline for all nodes
    include is_puppet_base::node_base

    # team SSH access
    include passwd_common

    # the necessary overloop environment in the desired branch
    class { 'overloop_env': branch => 'issue04_check_robustness' }

    # firewall rule allowing access from the Internet or a whitelist of IPs
    firewall { '300 API HTTPS     ': proto  => 'tcp', dport  => 443, action => 'accept', }

}
cd /home/deployment/overloop
sudo python3 setup_and_seed.py

The initialized database will be at /home/deployment/overloop/database.db.

Project Structure Notes

In both cases, the modules are loaded by using the __all__ variable in __init__.py, so be sure to update this if you add new files.

Example invocations

Internally:

curl http://localhost:8080/articles
curl http://localhost:8080/regions
curl http://localhost:8080/authors
curl http://localhost:8080/article/1
curl http://localhost:8080/region/1
curl http://localhost:8080/author/1
curl -X POST  http://localhost:8080/add_author  --form username=USERNAME --form password=PASSWORD --form 'content={"first_name":"Al","last_name":"Packa"}'
curl -X POST  http://localhost:8080/edit_author --form username=USERNAME --form password=PASSWORD --form 'content={ "id:9898989", "first_name":"Al","last_name":"Pacone"}' 
curl -X POST  http://localhost:8080/add_article --form username=USERNAME --form password=PASSWORD \
              --form 'content={ "title":"R0 versus 2020","content":"exponentially spreading literature blala", "authors":["1","2"], "regions":["1", "3"] }'
curl -X POST  http://localhost:8080/edit_article --form username=USERNAME --form password=PASSWORD \
              --form 'content={ "id":"3453455", "title":"R0 versus 2020","content":"exponentially spreading literature blala", "authors":["1","2"], "regions":["1", "3"] }'
curl -X POST  http://localhost:8080/delete_article --form username=USERNAME --form password=PASSWORD --form 'content={ "id":"3453455"}'

From the outside:

curl https://PUBLICURL/articles
curl https://PUBLICURL/regions
[...]

These invocations should return JSON content.