This Node.JS/Express app is a API lab server to train on how to call APIs using node-fetch or Postman
- Node.JS 10.16.x or above
- NPM
1/ Clone this git repository or download the zip into a folder
2/ Go inside this folder
3/ run npm install
run npm start
The web server will listen on port 3000.
E.g. http://localhost:3000/api
Ping-like function which returns a JSON object - meant to test connectivity
Return a text file
Request must contain as body a JSON object {username: , password: }. There is only one valid set of credentials:
- username: user1
- password: complex
Return a JSON object as response body confirming success as well as an authorization key in the response header cookie
-- Note: all other API calls below require authentication by passing in the request a header X-AUTH containing the authorization key received during the login process
Logout and discard the authorization token
Ping-like function which returns a JSON object - meant to test connectivity while authenticated
Return a JPEG file depending on the colour provided.
Only valid colours are red and yellow.