-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 870d955
Showing
60 changed files
with
8,654 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
/node_modules | ||
/test | ||
npm-debug.log | ||
.dockerignore | ||
/.idea |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
/node_modules | ||
/build | ||
/dist | ||
/.idea | ||
/test |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
FROM node:10 | ||
COPY package*.json ./ | ||
RUN npm install | ||
COPY . . | ||
ENV DOCKERIZE_VERSION v0.6.0 | ||
RUN wget https://github.com/jwilder/dockerize/releases/download/$DOCKERIZE_VERSION/dockerize-alpine-linux-amd64-$DOCKERIZE_VERSION.tar.gz \ | ||
&& tar -C /usr/local/bin -xzvf dockerize-alpine-linux-amd64-$DOCKERIZE_VERSION.tar.gz \ | ||
&& rm dockerize-alpine-linux-amd64-$DOCKERIZE_VERSION.tar.gz | ||
|
||
CMD dockerize -wait tcp://database:3306 -timeout 60m npm run start |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,99 @@ | ||
# 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 | ||
|
||
* http://localhost:3000/monitored-endpoints - GET/POST - get/create monitored endpoint | ||
|
||
* http://localhost:3000/monitored-endpoints - PUT/DELETE - update/delete monitored endpoint | ||
|
||
* http://localhost:3000/monitored-endpoints/:id/monitoring-results/ - GET - get monitoring results from monitored endpoint with specified id | ||
|
||
## Installation | ||
|
||
```bash | ||
npm install | ||
``` | ||
## Build | ||
|
||
```bash | ||
npm run build | ||
``` | ||
|
||
## Run | ||
|
||
```bash | ||
npm start | ||
``` | ||
|
||
## Test | ||
|
||
Basic unit tests using Jest | ||
```bash | ||
npm test | ||
``` | ||
|
||
## Docker | ||
|
||
```bash | ||
docker-compose up -d | ||
docker-compose up --build | ||
``` | ||
|
||
## Curl | ||
|
||
get monitored endpoints | ||
|
||
```bash | ||
curl -H "Authorization: Bearer 93f39e2f-80de-4033-99ee-249d92736a25" http://localhost:3000/monitored-endpoints | ||
``` | ||
|
||
create monitored endpoint | ||
|
||
```bash | ||
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 | ||
|
||
```bash | ||
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 | ||
|
||
```bash | ||
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 | ||
|
||
```bash | ||
curl -H "Authorization: Bearer 93f39e2f-80de-4033-99ee-249d92736a25" http://localhost:3000/monitored-endpoints/1/monitoring-results | ||
|
||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
version: '3' | ||
|
||
services: | ||
database: | ||
image: "mysql:5.7" | ||
container_name: "mysql" | ||
ports: | ||
- "3306:3306" | ||
volumes: | ||
- ./schema.sql:/docker-entrypoint-initdb.d/init.sql | ||
expose: | ||
- 3306 | ||
environment: | ||
MYSQL_HOST: database | ||
MYSQL_PORT: 3306 | ||
MYSQL_USERNAME: 'root' | ||
MYSQL_ROOT_PASSWORD: 'root' | ||
MYSQL_DATABASE: 'applifting' | ||
|
||
service: | ||
build: . | ||
image: "node" | ||
container_name: "nodejs" | ||
ports: | ||
- "3000:3000" | ||
depends_on: | ||
- database | ||
links: | ||
- database | ||
environment: | ||
MYSQL_HOST: database | ||
MYSQL_USERNAME: 'root' | ||
MYSQL_PORT: 3306 | ||
MYSQL_ROOT_PASSWORD: 'root' | ||
MYSQL_DATABASE: 'applifting' | ||
restart: on-failure | ||
|
||
|
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
module.exports = { | ||
roots: ['<rootDir>/src'], | ||
transform: { | ||
'^.+\\.ts?$': 'ts-jest', | ||
}, | ||
testRegex: '(/__test__/.*|(\\.|/)(spec))\\.ts?$', | ||
moduleFileExtensions: ['ts', 'js', 'json', 'node'], | ||
testEnvironment: 'node' | ||
}; |
Oops, something went wrong.