This a simple application to extract and display event logs. It consists of two applications:
-
backend
: A Node.js server with a single endpoint to read and parse a log file into a JSON array and filter the result based on some search variables. -
frontend
: A Next.js client application to collect the search variables through a form, fetch the events from thebackend
, and display the result.
- Update the
GET /events/log
endpoint implementation as described below. - Update the test cases.
-
Read the event log file from
./backend/data/events.log
. -
Parse the file content into an array of events with the following shape:
type Event = { timestamp: Date; userId: number; eventType: string; originalLine: string; };
-
Get the search variables,
fromDate
,toDate
,eventType
, anduserId
from query params and filter the events based on the following rules:userId
: return the events with the matchinguserId
.eventType
: return the events with the matchingeventType
.fromDate
andtoDate
: filter the events based on the date range.- all the search variables are optional.
-
Sort the result based on the
timestamp
in descending order and return the events. -
Update/Add the test case(s) to assert one or two scenarios.
- Add a simple form to collect search variables.
- Fetch the events from the
backend
. - Display the result.
- Do a simple validation on the form inputs.
- Note that all the search variables are optional.
tailwindcss
is just added for convenience, feel free to do the styling as you like.
- Clone this repository.
- Push it to your own public repository.
- Implement the solution in steps and make meaningful commits.
- Share the repository link with us.
This is not supposed to be an extensive task, so don't spend too much time on it. We are looking for a simple and clean solution.