Skip to content

Latest commit

 

History

History

api

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Audio Guide Bot: API service

API service is a dockerized Golang application that serves Guide Bot API and webhook for Telegram Bot API.

Configuration

Required environment variables:

  • TELEGRAM_WEB_APP_URL - URL to Guide UI service
  • TELEGRAM_BOT_TOKEN - Telegram Bot token
  • TELEGRAM_PAYMENTS_TOKEN - Telegram Payments token
  • JWT_SECRET - Secret to sign and verify JWT tokens
  • DB_CONNECTION_STRING - URL to DB
  • S3_CONNECTION_STRING - URL to S3

Optional environment variables:

  • CORS_ALLOWED_ORIGINS - list of allowed origins that may access the resource

Service structure

Service is built on three abstractions:

  • Providers - isolate interaction with other systems or packages
  • Repositories - provide CRUD operations for data types, all interfaces are implemented as an aggregate repository object
  • Controllers - implement HTTP handlers with business logic, all handlers are implemented in compliance with JSend specification

All entities are constructed and injected in main and then HTTP handlers are served by Fiber.

Database migrations

API service can be started in database migration mode. In this case, it will apply migrations from the implemented DBProvider and exit. To start the service in migration mode - specify --migrate execution argument.