Jakub-Vacek / MonitorService

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Description

Simple test server for monitoring urls. Uses MySql, Restify, Jest, TypeORM, Inversify.

Structure

  • authorization - service for token authorization

  • database - database layer, every entity has its model and repository, DatabaseProvider provides entity repository for service layer

  • http - simple axios service for getting responses from monitored endpoint url

  • logger - simple winston logger

  • monitor - monitor service handles monitoring of endpoint. Each instance of MonitoredJob is responsible for monitoring one monitored endpoint

  • monitored-endpoint - monitored-endpoint service layer

  • monitoring-result - monitoring-result service layer

  • validation - services for monitored endpoint validation. Based on class-validator/class-transformer

  • web - handles user interaction with server

  • inversify.config - class responsible for configuration of Inversiy container

  • app - application entrypoint

  • server - represents application server

Routes

Installation

npm install

Build

npm run build

Run

npm start

Test

Basic unit tests using Jest

npm test

Docker

docker-compose up -d
docker-compose up --build

Curl

get monitored endpoints

curl -H "Authorization: Bearer 93f39e2f-80de-4033-99ee-249d92736a25" http://localhost:3000/monitored-endpoints

create monitored endpoint

 curl -H "Authorization: Bearer 93f39e2f-80de-4033-99ee-249d92736a25" -H "Content-Type: application/json" -d '{"name": "test", "url": "http://private-264465-litackaapi.apiary-mock.com/cards/1/state", "monitoredInterval": 3}' http://localhost:3000/monitored-endpoints

update monitored endpoint

curl -X PUT  -H "Authorization: Bearer 93f39e2f-80de-4033-99ee-249d92736a25" -H "Content-Type: application/json" -d '{"name": "test", "url": "http://private-264465-litackaapi.apiary-mock.com/cards/1/state", "monitoredInterval": 3}' http://localhost:3000/monitored-endpoints/1/

delete monitored endpoint

curl -X DELETE  -H "Authorization: Bearer 93f39e2f-80de-4033-99ee-249d92736a25" -H "Content-Type: application/json" http://localhost:3000/monitored-endpoints/1/

get monitoring results

curl  -H "Authorization: Bearer 93f39e2f-80de-4033-99ee-249d92736a25" http://localhost:3000/monitored-endpoints/1/monitoring-results

About


Languages

Language:TypeScript 98.5%Language:Dockerfile 1.0%Language:JavaScript 0.5%