Currently each new client requests /api/messages from the server, which fetches the most recent page of messages from twilio. There's not currently a way to get more messages
There's no foreseeable way to store which user sent the message
We need to add multi-user authentication, so we'll have to have some sort of database anyway, and it'd be a pain to code that functionality
Proposed solution: a realtime database (pouchdb/horizon.io)
On server start:
If db empty, fetch the most recent 3(?) pages of messages from twilio
If db not empty, fetch messages since the latest record in the DB (may require multiple requests)
Auth handled by built-in auth system in db
Outbound requests from client get put into an outbound namespace. The server listens for new messages here, sends them to twilio, and updates them in the DB
This may provide a solution for #2 as well
Inbound requests work completely differently; they have their own REST route, validate that the request came from twilio, and add the record to the db.
Problem:
/api/messages
from the server, which fetches the most recent page of messages from twilio. There's not currently a way to get more messagesProposed solution: a realtime database (pouchdb/horizon.io)
outbound
namespace. The server listens for new messages here, sends them to twilio, and updates them in the DB