/fake-token-api

Fake token API

Primary LanguageJavaScriptMIT LicenseMIT

Fake Token API

Fake Node/Express API used to test token-based authentication.

Project Setup

  1. Fork/Clone
  2. Install Dependencies - npm install
  3. Run - npm start

Endpoints

  1. GET http://localhost:1337/ping
  2. POST http://localhost:1337/register
  3. POST http://localhost:1337/login
  4. GET http://localhost:1337/status

Requests

Register

Success:

$ curl http://localhost:1337/register \
  -H "Content-Type: application/json" \
  -X POST \
  -d '{"email":"test@test.com", "password": "test"}'

{
  "status": "success",
  "token": "1234567"
}

Failure:

$ curl http://localhost:1337/register \
  -H "Content-Type: application/json" \
  -X POST \
  -d '{"email":"not@right.com", "password": "test"}'

{
  "status": "error"
}

Login

Success:

$ curl http://localhost:1337/login \
  -H "Content-Type: application/json" \
  -X POST \
  -d '{"email":"test@test.com", "password": "test"}'

{
  "status": "success",
  "token": "1234567"
}

Failure:

$ curl http://localhost:1337/login \
  -H "Content-Type: application/json" \
  -X POST \
  -d '{"email":"bad@email.com", "password": "test"}'

{
  "status": "error"
}

Status

Success:

$ curl http://localhost:1337/status \
  -H "Content-Type: application/json" \
  -H "Authorization: Token 1234567"

{
  "status": "success"
}

Failure:

$ curl http://localhost:1337/status \
  -H "Content-Type: application/json" \
  -H "Authorization: Token incorrect"

{
  "status": "error"
}