Skip to content

Brew8it/REST-backend

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

15 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

REST-backend for simple CRUD operations.

REST-backend is a RESTful API that serves as a backend for a public message board.

It supports the simple CRUD operations (C)reate, (R)ead, (U)pdate, (D)elete:

A user can create a message in the service
A user can modify their own messages
A user can delete their own messages
A user can view all messages in the service

Assumption: Validation of username/ID is assumed to have been validated by another REST endpoint.

The API uses Python and MongoDB, it uses the following dependencies:

Thanks to Flask-RestPlus we get a nice Swagger UI for easy visualisation on the API as well as documentation and being able to test out the API. REST-Backend Swagger UI

Getting Started

Prerequisites

You will need both Docker and Docker-compose:

Docker installation guide:

Arch Linux:

sudo pacman -S docker
systemctl start docker.service
systemctl enable docker.service
groupadd docker
gpasswd -a user docker [replace user with your username]
relogin to apply the group change

Ubuntu: Docker offical ubuntu guide

Docker-compose installation guide:

Arch Linux & Ubuntu:

sudo curl -L "https://github.com/docker/compose/releases/download/1.24.0/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
sudo chmod +x /usr/local/bin/docker-compose

Running REST-Backend

Clone the repo:

git clone https://github.com/Brew8it/REST-backend.git && cd REST-backend

Build and start our docker image and start our mongodb service

sudo docker-compose up --build

You will now be able to navigate to the following url and start using swagger UI test the API from there

http://localhost:4000/api/

Or if you want to use curl:

A user can create a message in the service

curl -X POST "http://localhost:4000/api/Message/" -H "accept: application/json" -H "Content-Type: application/json" -d "{ \"user_id\": 0, \"msg_id\": 0, \"message\": \"string\"}"

A user can modify their own messages

curl -X PUT "http://localhost:4000/api/Message/" -H "accept: application/json" -H "Content-Type: application/json" -d "{ \"user_id\": 0, \"msg_id\": 0, \"message\": \"string\"}"

A user can delete their own messages

curl -X DELETE "http://localhost:4000/api/Message/" -H "accept: application/json" -H "Content-Type: application/json" -d "{ \"user_id\": 0, \"msg_id\": 0, \"message\": \"string\"}"

A user can view all messages in the service

curl -X GET "http://localhost:4000/api/Message/" -H "accept: application/json"

About

REST-backend for simple CRUD operations.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published