Simple server to check if endpoints are up and running.
- Node.js 16+
- Docker
Install the node dependencies:
npm install
Create a .env
file, you can simply copy the .env.sample
one, and default values will work with the configuration set in docker-compose.yml, but if you need to use a separate MariaDB instance, you will need to change that accordingly.
Set the list of endpoints to check by creating a jobs.json
, and creating an jobs
array, and each record should have the following object:
{
"url": "https://microsoft.com/",
"method": "HEAD",
"cron": "*/1 * * * * *",
"name": "microsoft-homepage"
}
The properties are the following:
url
The http request to testmethod
The http method for the requestcron
A cronjob string, more info can be found herekey
A urlencoded string to use as a Key to identify the request
A full sample can be seen here:
{
"jobs": [
{
"url": "https://microsoft.com/",
"method": "HEAD",
"cron": "*/1 * * * * *",
"name": "microsoft-homepage"
},
{
"url": "https://google.com/",
"method": "GET",
"cron": "*/5 * * * * *",
"name": "google-homepage"
}
]
}
Run MariaDB with Docker by running:
docker-compose up -d
To create the necessary tables, please run the migrations script:
npm run create:db
To start it in development mode please run:
npm run dev
To start it a production node process:
npm start
You can run migrations via an npm script to keep your db up to date, just run the following:
npm run update:db
GET /jobs/status
- Get the list of all the jobs with the most recent status
GET /jobs/logs
- Get the list of all the records for all jobs
Params:
limit
- Set the limit of records, defaults to 100offset
- Set the offset of records, defaults to 0
POST /jobs
- Create a new job in the database and add the related cronjob to the queue
Params:
name
- Name, or Key, to use to identify the jobcron
- A cronjob string that can be generated here.method
- The http method to use for the requesturl
- The url to test
Example:
// POST /jobs
{
"name": "dev-to",
"cron": "*/5 * * * * *",
"method": "GET",
"url": "https://dev.to"
}
PATCH /jobs/:id
- Update an existing job in the database and updates the related cronjob to the queue
Params:
id
- The ID of the jobname
- Name, or Key, to use to identify the jobcron
- A cronjob string that can be generated here.method
- The http method to use for the requesturl
- The url to test
Example:
// PATCH /jobs/1
{
"name": "dev-to",
"cron": "*/5 * * * * *",
"method": "GET",
"url": "https://dev.to"
}
DELETE /jobs/:id
- Delete an existing job in the database and removes the related cronjob from the queue
Params:
id
- The ID of the job
- Create basic endpoints for CRUD operations
- Create CLI to handle installation/migrations
- Create UI to see logs