Skip to content

Latest commit

 

History

History
69 lines (53 loc) · 2.93 KB

README.md

File metadata and controls

69 lines (53 loc) · 2.93 KB

Onidata DRF Project

Project made with Django + PostgreSQL + DRF for Onidata interview

Install

Docker + docker-compose

Install docker-ce and docker-compose from each documentation

Setting up

On the project folder run the following commands:

  1. $ make config.env to copy the file .env.example to .env
  2. $ make build to build docker containers

Running the project

Simply run the command $ make up and voilà.

This command will start 3 services on your machine:

Tests

On the project folder:

  • run the command $ make test or $ make test app=$(app_name). You may run the command $ make coverage instead.
  • run the command $ make flake8

Administration

Django Admin Site is enabled for the project on http://0.0.0.0:8000/admin.

The command $ make populate.superuser may be used to create the superuser User(username='superuser', password='@Admin123').

Using the API

Access the localhost server and browse the api.

DRF Coreapi Documentation coreapi documentation

You may interact with the API via browser or via http request softwares such as Insomnia

Authentication

BasicAuthentication, SessionAuthentication and JWTAuthentication are enabled on the API.

JWTAuthentication

Pass the token following the curl example. If there's some confusion about JWT read about it on JWT Oficial Documentation or the lib drf-simplejwt

curl \
  -H "Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VyX3BrIjoxLCJ0b2tlbl90eXBlIjoiYWNjZXNzIiwiY29sZF9zdHVmZiI6IuKYgyIsImV4cCI6MTIzNDU2LCJqdGkiOiJmZDJmOWQ1ZTFhN2M0MmU4OTQ5MzVlMzYyYmNhOGJjYSJ9.NHlztMGER7UADHZJlxNG0WSi22a2KaYSfd1S-AuT7lU" \
  http://localhost:8000/api/some-protected-view/

Insomnia Setup

Install Insomnia Rest from the official website.

Import the file insomnia_data.json located on the project folder.

import file insomnia import

Activate the Onidata workspace and Onidata environment

workpsace onidata workspace

enviroment onidata environment

Major libs used