Skip to content

Erlix322/CareGardenAPI

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 

Repository files navigation

CareGardenAPI

Motivation

Since my software engineering professor was recently talking about common software architectures, I decided to dive into the world of Node.js. This little RESTful service is the result of the last week and I'd like to share this code with you guys!

Aim of this Work

Within my "software engineering 2" course I have to work together with an amazing team to build a little application as a student project and we decided to follow the (3-tier) architecture. Although, this kind of architecture is quite easy to understand and also to implement, it became clear that at some point it gets difficult. Especially when it comes to authentication processes, the 3-tier architecture is not the best way to go. Therefore I decided to go forth to tier-4!

##Usage

  1. clone this projekt

git clone https://github.com/Erlix322/CareGardenAPI.git

  1. install Node.js

installation guide

  1. adjust the configurations

data/database.js to your own configuration In server.js you have to adjust the routes to your own needs and as a consequence you also have to adapt the queries

Workflow

  1. open up the browser and try to open a route which is NOT allowed without a token e.g http://localhost:8080/api/therapists

you will get an error for not having a valid token

  1. goto http://localhost:8080/api/login

here you enter the data of one of your users in your database

  1. if everthing is alright, you should be able to see a generated token

  2. try again to access http://localhost:8080/api/therapists?token=[your token]

now everything should be fine

Test with command line tool curl

curl --data "username=yourusername&password=yourpassword" http://localhost:8080/api/login
Response:

<title></title>

Herzlich willkommen T0001

Dein Token lautet: eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJuYW1lIjoiVDAwMDEiLCJwYXNzd29yZCI6IlRoZXJhcGV1dCIsImlhdCI6MTQ2MzIxMjI1MCwiZXhwIjoxNDYzMjEzNjkwfQ.NyKF4V__k67PTtl3fydN4Bg6VEjKDhii9-WDGBvUy44

Logout<script src="http://code.jquery.com/jquery.js"></script><script src="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.2/js/bootstrap.min.js"></script>

curl -X GET 'http://localhost:8080/api/patients' -d "token=yourtoken"

Response in case of this repository
[{"P_ID":"P0001","name":"Brandt","vorname":"Eric","Adresse":"Ericstraße 4","Telefon":"0815/12345","Diagnose":"AOK Plus","Krankenkasse":"Hist","Password":"test"},{"P_ID":"P0002","name":"Brandt","vorname":"Felix","Adresse":"Ericstraße 4","Telefon":"0815/12345","Diagnose":"AOK Plus","Krankenkasse":"Hist"}]

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published