Skip to content

Latest commit

 

History

History
67 lines (56 loc) · 1.51 KB

readme.md

File metadata and controls

67 lines (56 loc) · 1.51 KB

Simple REST chat

Simple REST chat application for demo purposes. This application could be also possible using ReactPHP and WebSockets.

Setup

Information for setting up the development environment is at setup.md

Users

There are 2 users for demo purposes

# Demo User 1
[email protected]
user1password

# Demo User 2
[email protected]
user2password

Authentication

The application is using simple authentication. You need to login using user credentials, retrieve the auto-generated token an pass an Authorisation header

Any attempt for unauthorised access throws JSON Response with 401 status code.

GET api/users/1/messages
> {"error":"Unauthorized"}

A user must login in order to retrieve his api_key

POST api/login
[email protected]
password=user1pass
> {"status":"success","api_key":"XXXXXXXX"}

Post new message

A user can post a new message to a specific receiver (another user id).

# Headers/key: Authorization (or HTTP_Authorization) : XXXXXXXX
POST api/messages
> 200 {"status":"success","result":{}}

Retrieve MessagesBySender

A user can retrieve all its messages from a specific sender (another user id).

# Headers/key: Authorization (or HTTP_Authorization) : XXXXXXXX
GET api/users/1/messages
> 200 {"status":"success","result":{}}

Tests

Tests are located under the /tests directory

vendor/bin/phpunit

Teardown

You can teardown be using the following command:

docker-compose -f docker-compose.local.yml down