Skip to content
This repository was archived by the owner on Aug 27, 2024. It is now read-only.

ValeryChapman/notifier

Repository files navigation

Notification microservice

Notifier is an example of a simple notification microservice. It is written in the Golang language. It uses RabbitMQ for message broker and MongoDB to store data.

Contents

Service scheme

Start app

  1. Build go.sum files
# build for consumer
$ cd ./consumer
$ go mod tidy

# build for sender
$ cd ./sender
$ go mod tidy
  1. Start app
# to start standard dev mode
$ make start-dev

# to start standard production mode
$ make start-prod

# to start the dev daemon
$ make start-dev-d

# to start the production daemon
$ make start-prod-d

Start tests

  1. Install HTTPie command-line HTTP client
# brew
$ brew install httpie

# apt
$ apt install httpie

# pip
$ pip3 install httpie
  1. Start bash tests
# change access rights for `tests.sh`
$ chmode 777 ./tests.sh

# start tests
$ sh ./tests.sh

API Documentation

API Constitution

Request-response scheme

Request format

{} // dictionary, array or other query parameters

Response format

// Success:
{
    "status": "success", // status success
    "data": {}  // dictionary, array or other request results
}
// Error:
{
    "status": "error", // status error
    "error": {
        "code": 2000, // custom error code
        "message": "" // short error description
    }
}

Error codes

Custom code HTTP code Description
404 404 Route not found
505 505 Method not allowed
500 500 Internal server error
2000 400 Validation error
2010 400 Object not found

Endpoints

New notification

Method: POST
/api/notifications/

Request body scheme:

{
  "to": [],      // e-mails for mailing
  "subject": "", // mail subject
  "body": ""     // mail body
}

Response body scheme:

{
    "status": "success",  // operation status
    "data": {
        "id": "",         // notification id
        "created_at": "", // date of create
        "updated_at": "", // date of update
        "to": [],         // e-mails for mailing
        "subject": "",    // mail subject
        "body": "",       // mail body
        "completed": true // completed status
    }
}

Get notification

Method: GET
/api/notifications/:id

Response body scheme:

{
    "status": "success",  // operation status
    "data": {
        "id": "",         // notification id
        "created_at": "", // date of create
        "updated_at": "", // date of update
        "to": [],         // e-mails for mailing
        "subject": "",    // mail subject
        "body": "",       // mail body
        "completed": true // completed status
    }
}

Get notifications

Method: GET
/api/notifications/?limit=<int>&offset=<int>&to=<[]str>

Response body scheme:

{
    "status": "success",    // operation status
    "data": [
        {
          "id": "",         // notification id
          "created_at": "", // date of create
          "updated_at": "", // date of update
          "to": [],         // e-mails for mailing
          "subject": "",    // mail subject
          "body": "",       // mail body
          "completed": true // completed status
        }
    ]
}

About

Notifier is an example of a simple notification microservice. It was written in the Golang language. It uses RabbitMQ for message broker and MongoDB to store data.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors