Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/marvin9/uptime-server-microservice


https://github.com/marvin9/uptime-server-microservice

Last synced: about 21 hours ago
JSON representation

Awesome Lists containing this project

README

        

# Uptime server API
[![Build Status](https://travis-ci.com/Marvin9/uptime-server-microservice.svg?token=VLAzbJP7VasfzqzWUHz9&branch=master)](https://travis-ci.com/Marvin9/uptime-server-microservice)

> Monitor your server uptime easily.

## Run locally.

- Download dependencies.

```go mod download```

- Setup environment variables in ```.env``` file.

- ```PSQL_USER:postgres```
- ```PSQL_PASSWORD:password```
- ```DATABASE_NAME:uptime_server_service```
- ```DATABASE_URL:postgres://postgres@localhost:5432/uptime_server_service```
- ```JWT_KEY:secret_key```
- ```SENDGRID_API_KEY:your_sendgrid_api_key```
- ```COOKIE_DOMAIN:localhost```
- ```ALLOW_ORIGIN:http://localhost:3000```

> NOTE: Update DATABASE_NAME & DATABASE_URL before running tests.

- Run.

```make dev```

OR

```go run main.go```

- Test.

```make test```

```make verbose_test``` to debug tests.

## API


Endpoint
Method
Request Body
Response
Additional


/auth/register
POST


{
"email": string,
"password": string,
}




{
"email": bool,
"password": string,
}




/auth/login
POST


{
"email": string,
"password": string
}




{
"error": bool,
"message": string
}



Set jsonwebtoken in http cookie with expiration time of 30 minutes.



/auth/ping
GET
-


{
"email": string,
} ||
{
"error": boolean,
"message": string.
}




/api/instance
POST


{
"url": string,
"duration": int (time in nanoseconds)
}




{
"error": bool,
"data": string
}


Set monitor for url which will check in duration period and update database accordingly. Reflects in /api/report


/api/instances
GET

-



{
"error": bool,
"data": {
"url": string,
"duration": int,
"unique_id": string,
} || "message": "Unauthorized"
}


-


/api/report
GET

-



{
"error": bool,
"data": {
"url": string,
"status": int,
"reported_at": time,
"instance_id": string,
} || "message": "Unauthorized"
}


-


/api/instance
DELETE


{
"instance_id": string,
}




{
"error": bool,
"message": string
}


-