Challenge Overview
In this challenge we will build a simple REST service that will connect to Kafka as a producer and will expose the following endpoints:
-
POST /event - post a new event to the kafka queue. Parameters:
-
type:String (fully qualified name - dot separated string; ex connect.project.update, challenge.created)
-
message: String (json formatted)
-
This endpoint will post the message to kafka. We want to avoid cluttering global topic namespace so all topics for this producer will be prefixed with “notifications.”, like “notifications.connect.project.update”. Create a helper for validating messages based on source system, message type and contents. We don't have any hard requirements for message validation yet, so validation should essentially be a no-op for now (all messages are passing validation).
-
GET /topics - it will retrieve just a list of topics in kafka
All api requests should be authorized using a JWT token with payload as {name:”name of the service that creates the event”} and a list of allowed services is kept in a configurable list. JWT secret and expiration time should be configurable (environment variables).
Connection to Kafka will be made over SSL using certificates, so KAFKA_URL, KAFKA_CLIENT_CERT and KAFKA_CLIENT_CERT_KEY should be configurable via environment variables. Use no-kafka npm module for interacting with Kafka.
For this challenge we have a kafka service deployed at Heroku. Post your handle in the forums to get the URL, certificates and sample topics you can use for testing.
Final Submission Guidelines
Submit a complete source code for the service
Submit a Deployment guide for deploying locally and on Heroku
Submit a Postman collection for verifying the endpoints (and instructions to verify the messages end up in kafka queue)
Submit a Swagger API spec