Lightweight SSE mock-server configurable "on the fly" through the interactive CLI-prompt
Front-end developers who might need to mock responses from the actual back-end with the data of their choice or whoever else who might find this useful
- Clone the repo
git clone https://github.com/ygorbunkov/sse-mock.git
- Install the dependencies
yarn install
- Configure the environment (set necessary parameters within .env file)
- Create JSON-files in response directory (/src/response, by default) that will be used as a mock-data for Server Sent Events
- Start the server
yarn start
- When prompt is available in the terminal go to 'Configure endpoint subscription response'
- Specify route path (part that comes after root prefix) for your mock endpoint (e.g. /status-event to get http://localhost:3000/sse/status-event)
- Pick JSON-file from the list (it will be used as a data source for SSE)
- Whenever you need to push SSE event to the client hit 'Push Server Sent Event to the client' in the prompt
- Once you're done using the app hit 'Exit'
Yes. However, you might need Docker Engine and Docker Compose for that.
You may either clone the repo (as suggested above), build Docker image locally and run it
docker-compose run ssemock
Or you may spin the latest image from the Dockerhub
Note: by default, your local ./response directory will be mounted as a Docker volume to ssemock container to host JSON-files with mock responses