
Security News
The Changelog Podcast: Practical Steps to Stay Safe on npm
Learn the essential steps every developer should take to stay secure on npm and reduce exposure to supply chain attacks.
github.com/jklewa/batched-event-api
Advanced tools
This project consists of a web service designed to handle incoming user event data.
The service receives newline-delimited JSON via HTTP POST requests, converts the data into CSV format, and writes the data to disk in 5-minute intervals based on the timestamp of each event.
See ./api/handler/userevent.go
The web service:
POST HTTP request with a payload containing User Event data.time field across requests.The web service:
200 OK status after reading the request payload.time field.Two POST /user/event requests are made:
2024-07-01T02:03:04Z with the last event at 2024-07-01T02:11:05Z, occurring every second.2024-07-01T02:12:06Z with the last event at 2024-07-01T02:15:07Z, occurring every second.This results in 3 CSV files:
2024-07-01T02:03:04Z to 2024-07-01T02:08:04Z.2024-07-01T02:08:04Z to 2024-07-01T02:13:04Z.2024-07-01T02:13:04Z to 2024-07-01T02:18:04Z.See ./api/handler/userevent_test.go
Docker Compose
# Run the web service
docker compose up
Locally
# Run the web service
go run main.go -o ./data
Use a tool like curl or Postman to send POST requests with the required NDJSON payload to the web service endpoint.
curl --request POST \
--url http://localhost:8080/user/event \
--header 'Content-Type: application/x-ndjson' \
--data-binary @data/initial-dataset-01.ndjson
Tests covering api/handler/userevent.go are in api/handler/userevent_test.go and can be run with go test.
go test ./...
> ok github.com/jklewa/batched-event-api/api/handler 0.201s
FAQs
Unknown package
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
Learn the essential steps every developer should take to stay secure on npm and reduce exposure to supply chain attacks.

Security News
Experts push back on new claims about AI-driven ransomware, warning that hype and sponsored research are distorting how the threat is understood.

Security News
Ruby's creator Matz assumes control of RubyGems and Bundler repositories while former maintainers agree to step back and transfer all rights to end the dispute.