itwithlyam / AccountsAPI

Repository from Github https://github.comitwithlyam/AccountsAPIRepository from Github https://github.comitwithlyam/AccountsAPI

AccountsAPI

A template API for a basic accounts system.

Methods

  • GET
  • POST
  • PUT
  • PATCH
  • DELETE

Authorization

Access tokens to be set in administrators.json

Schema

"username": {
    "name": 1 (number),
    "level": Permission level (number),
    "check": Access token (string),
    "method": Hashing algotrithm (string)
}

Level 1

  • Home access
  • GET access
  • POST access
  • PUT/PATCH access
  • DELETE access
  • ROOT access

Level 2

  • Home access
  • GET access
  • POST access
  • PUT/PATCH access
  • DELETE access
  • ROOT access

Level 3

  • Home access
  • GET access
  • POST access
  • PUT/PATCH access
  • DELETE access
  • ROOT access

Level 4

  • Home access
  • GET access
  • POST access
  • PUT/PATCH access
  • DELETE access
  • ROOT access

Running

The API is built on Python, which means that it is easy to run.

Dependencies:

mysql.connector: pip install mysql.connector

flask: pip install flask

waitress: pip install waitress

Deployment

  1. Create a new virtual envrionment using python -m venv venv
  2. Move the files into the virtual environment
  3. Activate the virtual environment via bash bin/activate on MacOS and Linux or scripts/activate on Windows
  4. Install waitress as shown above and run waitress-serve --port 80 "v2:app". On MacOS and Linux, run this with sudo permissions.
  5. Head to 127.0.0.1 (localhost) and onto your desired enpoint.

Test suite

  1. Install Node.JS and npm: https://nodejs.org
  2. Install node-fetch using npm install node-fetch
  3. Edit the test suite to your desired enpoint and URL
  4. Run node testing.js in a different terminal to the one with your API. Make sure you keep the API running!

About


Languages

Language:Python 100.0%