This demo app lets you monitor selected URLs by periodically sending requests to them and storing responses that can be viewed in the browser using the frontend app.
TBD
If you have Docker installed, you should be able to start the app simply by running
docker-compose up
If that works for you, proceed to the Usage section.
For non-Docker development, please continue reading.
First we need to install Node dependencies using our favourite packages manager in the root of the project, f.e.
yarn
# or
npm install
We have separate development servers for backend (using nodemon
and ts-node
) and frontend (using Next.js
).
To start both servers simultaneously, run
yarn dev
# or
npm run dev
Frontend is served at http://localhost:3000
Backend is served at http://localhost:8080
Code changes are propagated without having to manually restart the servers.
We use concurrently
package to run multiple npm scripts at the same time, ensuring cross-platform compatibility.
Before running the app, we need to have a valid .env
file in the /server
folder where we store our secrets. Simply rename the .env.default
file to .env
and fill in the empty values.
FAUNA_DB_SECRET=
JWT_SECRET=
In order to test the app, we first need to get an accessToken via the /login
endpoint.
password | |
---|---|
[email protected] | batman |
We're using a modern serverless database FaunaDB.
List of available endpoints:
Login
Get monitor
Create monitor
Edit monitor
Delete monitor
List results
Clear results
Log in with username/password and receive access token.
Header | Value |
---|---|
Authorization | Basic Base64<username:password> |
Response | Value |
---|---|
200 | accessToken: string |
401 | Wrong credentials |
All monitor endpoints require authentication with access token and share the following responses
Header | Value |
---|---|
Authorization | Bearer <accessToken> |
Response | Value |
---|---|
400 | Wrong request params |
401 | Wrong credentials |
404 | Monitor settings not found |
Response | Value |
---|---|
200 | MonitoredEndpoint |
Request body:
{
"name": "test",
"url": "https://httpbin.org/status/200",
"monitoredIntervalSeconds": 60
}
Response | Value |
---|---|
200 | Monitor ID |
Request body:
{
"name": "test",
"url": "https://httpbin.org/status/200",
"monitoredIntervalSeconds": 60
}
Response | Value |
---|---|
204 | - |
Response | Value |
---|---|
204 | - |
All results endpoints require authentication with access token
Header | Value |
---|---|
Authorization | Bearer <accessToken> |
Response | Value |
---|---|
200 | Array<MonitoringResult> |
Clears all results for all users. Technically this should be only accessible by some Admin user but more granular permissions are out of scope of this demo.
Response | Value |
---|---|
204 | - |
yarn test
# or
npm test