Skip to content

Marvin9/uptime-server-microservice

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

95 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Uptime server API

Build Status

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 } -

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Packages

No packages published