/greeting-with-auth

Application that greets authenticated users

Primary LanguageJavaScript

greeting-with-auth

Application that greets authenticated users.

Usage

Setup

To load modules, run:

npm install

Start

To start the app, run:

npm run start

NOTE: App starts on port 8080 by default.

To customize the port, use PORT environment variable. For example:

PORT=3000 npm run start

Tests

To run tests, run:

npm run test

Tests include several groups of unit tests and a couple of end-to-end tests.

API

This app has only two routes: login and greeting.

Login

POST /login

This route returns authentication token by user's credentials.

Credentials are accepted as a JSON of the format:

{
    "name": "User name",
    "password": "User password"
}

For testing, use the following credentials:

{
    "name": "PoliteUser",
    "password": "GoodMorning"
}

Example

Request:

POST http://localhost:8080/login
{
    "name": "User name",
    "password": "User password"
}

Response:

"AuthToken"

Greeting

GET /greeting

This route returns greeting string for authenticated users.

Authentication is performed by providing a valid auth token in X-Auth-Token header.

Example

Request:

GET http://localhost:8080/greeting

Response:

"Hello!"

Limitations

This app has several known limitations:

  • There is no validation of input parameters.
  • There is no documentation generated apart of the description in this document.
  • Database implementation has been simplified to a hardcoded list of users, containing one test user. It is not covered with tests.
  • Authentication process is simplified to the search of user by his credentials or token.

Notable Features

This project uses: