- dev - dev or prod
- configFilepath - filepath to config.toml file
- logLevel - trace / debug / info
- $PORT - just listen port, defaults to 8080
- $DATABASE_URL - url to database in format of "postgres://127.0.0.1:5432"
- $SECRET_KEY - it's key for cookie store, server using this store to store login data.
- $SENDGRID_KEY - key for sendgrid.com, I'm using it as backend for sending emails.
- Message
{"user": "user", "chat": "chat", "id": "id", "text": "text", "time": "time"}
- User
{"user": "user"}
{"email": "user@example.org"}
- Chat
{"chat": "chat"}
- Events
- LoginEvent, LogoutEvent, ChatJoinEvent, ChatLeaveEvent
{User, Chat, Time}
- MessageEvent
{Message}
- ChatCreatedEvent, ChatRemovedEvent
{Chat, Time}
- ChatReport: contains info about chat for concrete user. If not joined - fields "messages" and "users" are empty.
{
User,
Chat,
"joined":true,
"messages": [...Message],
"users": [...User]
}
- Server will store user in db and send a email with validation link to email.
- Method: POST
- Request:
{User, "email": "user@example.com", "password": "password"}
- Server will request send ResetPasswordToken via email.
- Method: POST
- Request:
{User}
- Server will generate hash for new password and store it.
- Method: POST
- Request:
{User, "passwordResetToken": "reset token from email", "password": "new password"}
- Server will set user activated status to true in database
- Method: GET
- Server will check if user is in database, if user had verified email and if password is correct, then force logins user.
- Method: POST
- Request:
{User, "password": "password"}
- Response: valid cookie with session token
- Login for unregistered users, only if user with this name isn't already logged in.
- Method: POST
- Response: valid cookie with session token and
User
- this routes are only for users with valid cookie, that can be acquired via upper routes
- Force logins user.
- Method: POST
- Response: valid cookie with session token and
User
- Logouts user.
- Method POST
- Updates user's last activity.
- Method: PUT
- Long poll for actions.
- Method: GET
- Response: Event
{"type": "EventType", "event": Event}
- Joins chat
- Method: POST
- Request:
Chat
- Response:
ChatReport
- Leaves chat
- Method: POST
- Request:
Chat
- Get all chats, joined status, messages for chats and users, if user permitted.
- Method: GET
- Response:
[...ChatReport]
- Gets last messages for a chat if is permitted
- Method: POST
- Request:
Chat
- Response:
[...Message]
- Posts message in chat if permitted
- Method: POST
- Request:
{User, "text": "text", Chat}
- Gets users in chat if permitted
- Method: POST
- Request:
Chat
- Response:
[...User]
- this routes are only for admins
- Creates new chat
- Method: POST
- Request:
Chat
- Removes a chat
- Method: POST
- Request:
Chat