Skip to content

witekosz/messg-api

Repository files navigation

messg-api

Example API with Django and Django Ninja.

API Docs: https://messg-api.herokuapp.com/api/docs

Available endpoints:

  • /api/messages/ GET - List all added messages
  • /api/messages/{message_id}/ GET - Retrive message, increments counter
  • /api/messages/{message_id}/ POST* - Add message
  • /api/messages/{message_id}/ PUT* - Update message, restet counter
  • /api/messages/{message_id}/ DELETE* - Delete message

* API key required


Development

SQLite database and Django development server.

Recomended poetry for local development.

You will need to add API key by django shell or manually in database.

poetry

  1. Go to project root directory
  2. Install and set environment:
    $ poetry install
    $ poetry shell
    $ cd messgapi
  3. Run tests:
    $ python manage.py tests
  4. Create a database:
    $ python manage.py migrate
  5. Run development server:
    $ python manage.py runserver
  6. The server should be running on: localhost:8000

docker

  1. Go to project root directory
  2. Build images:
    $ docker-compose build
  3. Run containers:
    $ docker-compose up -d
  4. Create a database:
    $ docker exec messg-api python manage.py migrate
  5. The server should be running on: localhost:8000

Deployment

Heroku, PostgreSQL and gunicorn.

Build manifest in heroku.yml.