Simple application for endpoint monitoring.
- typescript
- nest.js
- integration and unit tests examples
- docker-compose
- postgres
- graphql
- typeorm
- jwt authentication
- node.js (tested on v. 12.6.0)
- docker
- docker-compose
$ npm install
# development
$ npm run start:local
# integration tests
$ npm run test:integration
# unit tests
$ npm run test
- Lunch the app with
npm run start:local
. - The app will initialise existing endpoint-monitoring entities in the background, will start calling
GET
HTTP method for each of them in the specified interval and save the payload and the status to the database. - For adding a new endpoint to monitor, first create a new user:
- In the browser go to
http://localhost:3000/graphql
. - Paste the following mutation
mutation {
signup(
signUpInput: {
email: "[email protected]"
password: "password"
username: "user"
}
) {
id
jwt
}
}
- Copy the JWT from the response and use it as a Bearer token in the next steps
- Run the following migration to start monitoring Google every 20 seconds
mutation {
createMonitoredEndpoint(
monitoredEndpointInput: {
name: "google"
url: "https://google.com"
monitoredInterval: 20
}
) {
id
createdAt
}
}
- To get the monitoring result use this mutation
query {
monitoredEndpoints {
id
name
checkedAt
monitoringResult(first: 1) {
payload
statusCode
}
createdAt
}
}
This mutation will only display endpoints for the currently logged user based on JWT.
- Check the GQL schema, there are more mutations and queries there to play.
- Pagination.
- Options for search and ordering.
- Data streams.
- Split the API and Scheduler parts for better scalability.
- Data model is pretty simple, consider NoSQL as a storage.
- Better test-coverage.
- Consider Nest.JS code first approach for GraphQL. It can bring additional features like query complexity for free.
Nest is MIT licensed.