Skip to content

Latest commit

 

History

History
74 lines (51 loc) · 1.64 KB

README.md

File metadata and controls

74 lines (51 loc) · 1.64 KB

GESCO care Backend

Description

The Gesco care backend consists of Nodejs running an Express web server. A RESTful API is exposed through this web server.
Behind the scenes it is using Lowdb to store data locally in a json format. This is very usefull for testing and demonstration purposes, but should be replaced by a real database (i.e. MongoDB or MySQL) in a production environment.

Running the Server

To actually run the server you need to have Nodejs installed. Then simply run the command npm install and then start the server with either npm start or npm run dev.

API Overview

Open Endpoints

Open endpoints require no authentication.

  • Register: POST /register
  • Login: POST /login

Endpoints that require Authentication

Closed endpoints require a valid token to be included in the request. A token can be acquired from the Register or Login calls above.

  • Show personal info: GET /me

API Details

Login

Used to get a recieve a token for a registered user.

URL: /login
Method: POST
Authentication required: NO

Data Constraints

{
  "usernameOrEmail": "[valid username or email address]",
  "password": "[password in plain text]"
}

Data Example

{
  "usernameOrEmail": "[email protected]",
  "password": "abcdefg12345"
}

Success Response
Code: 200 OK
Content example:

{
  "token": "93144b288eb1fdccbe46d6fc0f241a51766ecd3d"
}

Error Response
Condition: If usernameOrEmail or password is wrong in combination or the user does not exsist.
Code: 400 BAD REQUEST
Content example:

{
  "error": "user does not exist"
}