This program was developed and tested using Node 14, but should be able to run using Node 10.
Bring up the containers to start the MySQL server:
npm run db:up
Wait for the server to start by watching the logs:
npm run db:logs
Once the server is up and running stop the logs with ctrl+c
Create the database schema by loading mysql/schema.sql:
npm run db:schema
You can connect to MySQL client using:
npm run db:client
All unit tests are in place with 100% coverage. To execute them run:
npm test
To run the server:
npm start
To subscribe to topic1
and have the messages viewable on /event1
:
curl -X POST \
--data '{"url": "http://localhost:8000/event1"}' \
-H "Content-Type: application/json" \
http://localhost:8000/subscribe/topic1
To publish an event to topic1
:
curl -X POST \
--data '{"messages": "message 1"}' \
-H "Content-Type: application/json" \
http://localhost:8000/publish/topic1
curl -X GET http://localhost:8000/event1