tvm-contest / devex-37-submission-3

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Contact

  • Telegram: @rukavkov
  • Surf: 0:392300ae37bdccb044a8e2ba13f9f3a2f966f26c53a776bc10706f2ed591487d

Repository(actual readme): https://github.com/nrukavkov/freeton-notification-service

FreeTON Notification Service

FNS (FreeTON Notification Service) is a http service allows you to forward encrypted messages from FreeTON Network to http(s) web services and Telegram.

Features

  • Guarantee delivery: no one loss even a server or service unavailable. FNS will repeat to try send a callback until it is done. Or until you want to stop it.
  • Easy to use auth system: just press the link and get an access to the private area.
  • Forward messages to http(s) and telegram.
  • Super user permissions for administration the service.
  • Visual pretty interface for quick seach and detect problems.
  • Easy deploy to Kubernetes.
  • API
  • Logging errors and many other things...

image

Before usage / Requirements

Before start using FNS you need to have.

  1. Serf wallet.

  2. External web address for receiving messages. For testing enough to use services like https://webhook.site. Open https://webhook.site and press the link https://webhook.site/0f0b0f73-11d8-4074-bd70-e03be5e19dee. You will receive an external https address which could be used for testing later. Do not forget enable CORS Headers. It is very important for testing.

image

How to use

  1. Open Serf and log in using your credentials.

  2. Switch to Test Network and get some Ruby using https://faucet.extraton.io/.

  3. Open Debot using Debot Browser or link. After the siging two transactions you will see the menu.

image

  1. Press the button Send callbackUrl | deviceToken to provider and choose github.com/nrukavkov/freeton-notification-service, ID = TNS from the list. Then enter data to the provider. By default you can use two types: HTTP(S) or TELEGRAM. Example of usage: https://webhook.site/0f0b0f73-11d8-4074-bd70-e03be5e19dee telegram://someChatId

image

ℹ️ Before receiving messages to Telegram, you have to create Telegram Bot using Bot Father, save Bot Token and add your bot to the some channel.

Open the secret link starts with https://freeton-notification-service.voip-lab.ru/login/{your_secret_api_key} and get an access to the private are where you can change your profile settings.

image

Also here you can see all messsages and status of delivery.

image

If you want to get more detailed info just press the ➕ near the intrested message.

image

  1. Then you need to Set Rules and follow the instruction received from Debot. At the first line you need to set up ID. In our case it will be generated ID=TNS. And the second line will be an address in blockchain and message type. Example of rules:
ID=TNS

# HERE YOU NEED TO USE YOUR OWN ADDRESS. IT IS JUST EXAMPLE.
0:392300ae37bdccb044a8e2ba13f9f3a2f966f26c53a776bc10706f2ed591487d all

ℹ️ For testing you can use your personal wallet address.

  1. Final step try to send some Rubi to addreess you set before. A few seconds later you will get POST requests to your endpoint.

image

Selfhosted version

If you want you can use self hosted version of FreeTON Notification Service. In this case you can have admin rights. It allows you to see all messages and enpoints. To get admin rights just set in mongodb isAdmin field to true for your endpoint.

API

POST / - set new endpoint

GET /endpoint - return all available endpoints

DELETE /endpoint:id - delete endpoint with ID

GET /message - get all my messages

DELETE /message/:id - delete message with ID

For Developers

The primary instance installed in Kubernetes Cluster. But you can start it locally using docker-compose up --build command. Required docker-compose and docker installed and .env with variables:

MONGODB_CONNECTION_STRING="mongodb://USERNAME:PASSWORD@HOST_OR_IP/DATABASE?authSource=admin"
SALT=CHANGE_ME
KAFKA_USERNAME=CHANGE_ME
KAFKA_PASSWORD=CHANGE_ME
KAFKA_MECHANISM=scram-sha-512
KAFKA_TOPIC=CHANGE_ME

Deploy

We use HELM and WERF for deploying the application to kubernetes.To do it just use the command below

werf converge --repo=ghcr.io/nrukavkov/freeton-notification-service

Local run

werf run app --docker-options="-ti --rm -p 8000:8000

About


Languages

Language:JavaScript 74.1%Language:Pug 22.9%Language:Dockerfile 1.7%Language:CSS 1.3%