Server component of G53SQM 14/15 coursework
npm install
Installs all dependencies found in package.json
.
npm run build
Builds source using Gulp.
npm run test
Performs tests using jasmine-node and Frisby.
npm start
Runs the server using supervisor.
For a fully functional Briefly client refer to mherod/Briefly-Client.
This API is used for app initialisation (authorising user, getting latest messages, retrieving current active users) as well as creating new messages and deauthorising the session.
curl -X POST -H "Content-Type: application/json" -d '{"username":"brodes","password":"password"}' \
https://briefly-chat.herokuapp.com/user
Username must be unique, password is stored unencrypted. If successful a success object is returned:
{
success: "User created"
}
curl -X POST -u 'username:pass' https://briefly-chat.herokuapp.com/auth
Returns a unique token if valid:
{
token: "12345",
username: "brodie"
}
curl -X DELETE https://briefly-chat.herokuapp.com/auth?token=12345
Returns a success object if successful:
{
"success": "Invalidated token"
}
curl -X POST -H "Content-Type: application/json" -d '{"message":"Hello world!"}' \
https://briefly-chat.herokuapp.com/message?token=12345
Returns message object if successful:
{
message: "Hello world!",
at: 1420025338,
from: "brodie"
}
curl -X GET https://briefly-chat.herokuapp.com/messages?token=12345
Returns last 10 messages (array of message objects) if successful.
curl -X GET https://briefly-chat.herokuapp.com/users/active?token=12345
Returns an array of user objects of active users. These users are deemed active based on whether they are connected to the Real Time API with a valid access token.
This API should only be used to provide Real Time updates to the client. When connected using a valid token the user will be marked as active. On disconnection or deauthorisation the user in question will be marked as inactive.
SocketIO.connect "https://briefly-chat.herokuapp.com/?token=abcdefgh"
SocketIO.on "message", (data) ->
Where data
is a valid message object.
SocketIO.on "users/active", (data) ->
Where data
is an array of user objects.