Code Monkey home page Code Monkey logo

everscale-notifications-service's Introduction

i4ins Everscale Notifications Service

Notifications Service for Everscale Blockchain. Service PROD version is already deployed here: https://ftns.freeton-stats.org/ and available via Notifications DeBot (Service ID - i4ins)

Features

  • Unique identifier and notification parameters - data is stored in MongoDB
  • Guaranteed delivery of notifications - notifications will be delivered even after service shutdown, repeated delivery for 24h in case if webhook consumer unavailable
  • Support for HTTPS protocol
  • Verification of a domain ownership - via adding a validation file in a .well-known folder
  • Logging of events of http notifications for the possibility of displaying them in charts - https://ftns.freeton-stats.org/log/info
  • All HTTP API methods must return a 200 response if the requested operation is successful and corresponding HTTP error code otherwise
  • Module information - available here https://ftns.freeton-stats.org/info/get
  • Well documented with openapi
  • http server with UI is provided for testing purposes

I. API Documentation

Api documention and schemas are provided here (openapi): https://ftns.freeton-stats.org/docs/api

II. Testing

Solution has a Demo server for testing purposes
Please, follow the guide in the repository: https://github.com/Strafi/everscale-notifications-service-demo

III. Installation

1. Clone this repo

$ git clone [email protected]:Strafi/everscale-notifications-service.git i4ins
$ cd i4ins

2. Install dependencies

$ npm install

or

$ yarn

IV. Environment

To edit environment variables, create a file with name .env and copy values below.
Note: if you are going to use docker-compose, you should also update environment in .yml files.

Var Name Type Default Description
NODE_ENV string development API runtime environment. eg: staging
PORT number 3000 Port to run the API server on
MONGO_URL string mongodb://mongo:27017/ftns URL for MongoDB
KAFKA_USERNAME string undefined Your username
KAFKA_PASSWORD string undefined Your password
KAFKA_TOPIC string undefined Your topic
KAFKA_GROUP_ID string undefined Your group id
KAFKA_BROKER string notification.services.tonlabs.io:29092 URL for tonlabs kafka broker

V. Run production docker image

1. Add your KAFKA_USERNAME and KAFKA_PASSWORD environment variables

2.1 Using docker-compose

$ docker-compose -f docker-compose.prod.yml up

2.2 Using docker

$ docker pull asolodkov/i4ins
$ docker run -t -i \
      --env NODE_ENV=production \
      --env MONGO_URL=mongodb://mongo:27017/ftns \
      --env KAFKA_USERNAME={YOUR_KAFKA_USERNAME} \
      --env KAFKA_PASSWORD={YOUR_KAFKA_PASSWORD} \
      --env KAFKA_TOPIC={YOUR_KAFKA_TOPIC} \
      --env KAFKA_GROUP_ID={YOUR_KAFKA_GROUP_ID} \
      --env KAFKA_BROKER=notification.services.tonlabs.io:29092 \
      -p 3000:3000 \
      asolodkov/i4ins

VI. Build and run from source

The mongo container is only only available in dev environment. When you build and deploy the docker image, be sure to provide the correct environment variables.

1. Build and run without Docker

$ npm run build && npm run start

or

$ yarn build && yarn start

2. Run with docker

$ docker build -t i4ins .
$ docker run -t -i \
      --env NODE_ENV=production \
      --env MONGO_URL=mongodb://mongo:27017/ftns \
      --env KAFKA_USERNAME={YOUR_KAFKA_USERNAME} \
      --env KAFKA_PASSWORD={YOUR_KAFKA_PASSWORD} \
      --env KAFKA_TOPIC={YOUR_KAFKA_TOPIC} \
      --env KAFKA_GROUP_ID={YOUR_KAFKA_GROUP_ID} \
      --env KAFKA_BROKER=notification.services.tonlabs.io:29092 \
      -p 3000:3000 \
      i4ins

3. Run with docker-compose

$ docker-compose up

VII. Logging

The application uses winston as the default logger. The configuration file is at src/logger.ts.

  • All logs are saved in ./logs directory and at /logs in the docker container.
  • The docker-compose file has a volume attached to container to expose host directory to the container for writing logs.
  • Console messages are prettified
  • Each line in error log file is a stringified JSON.

Application logs available here: https://ftns.freeton-stats.org/log/info

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.