Giter VIP home page Giter VIP logo

dao-api-gateway's Introduction

Astro API Gateway

Release version Build Launch API Autotests On Schedule Telegram group

Astro API Gateway contains list of services used by DAO applications based on Sputnik DAO Contracts version 2 on NEAR Protocol.

Main features:

  • Sync DAO Contracts data with the Database.
  • Provide API endpoints to interact with DAOs.
  • Produce DAO updates notifications.

Tech Stack

Services

  • Aggregator - sync blockchain historical data with the Database.
  • Indexer Processor - sync blockchain real-time data with the Database.
  • API - provides a set of API endpoints to view, filter, search, sync etc.
  • Draft - provides a set of API endpoints to manage draft proposals and comments.
  • Notifier - simple notification service for sending / subscribing on service events.

Services

Project Structure

Project has standard NestJS monorepo structure, where all services (aggregator, api, etc.) are separated on apps. All reusable modules separated on libs by domains and could be shared between different apps and libs itself.

Project Structure

Apps

/apps
  /aggregator
  /api
  /draft
  /indexer-processor
  /notifier

Libs

/libs
  /account
  /bounty
  /cache
  /comment
  /common
  /config
  /dao
  /dao-api
  /dao-settings
  /draft-comment
  /draft-proposal
  /error-tracker
  /event
  /migrations
  /near-api
  /near-indexer
  /notifi-client
  /notification
  /orm-migrations
  /otp
  /proposal
  /proposal-template
  /sputnikdao
  /stats
  /subscription
  /token
  /transaction
  /transaction-handler
  /utils
  /websocket

Config

Main config properties could be specified by environment variables defined in .env file.

All the configs are managed by config lib and shared between apps and libs.

/libs/config/src
  /aggregator-config.ts
  /api-config.ts
  /cache.ts
  /configuration.ts
  /dao-api.ts
  /database.ts
  /database-draft.ts
  /database-near-indexer.ts
  /draft-config.ts
  /indexer-processor-config.ts
  /near.ts
  /near-api.ts
  /near-config.ts
  /near-token-factory.ts
  /notifi.ts
  /notifier-config.ts
  /redis.ts
  /typeorm-config.service.ts

Getting Started

Local Development

  1. Clone the repo:
git clone [email protected]:near-daos/astro-api-gateway.git
  1. Open the repo folder:
cd astro-api-gateway
  1. Install dependencies:
yarn
  1. Add .env.local to the root folder with required environment variables described in .env.

  2. Run dev docker compose:

docker-compose -f docker-compose-dev.yml up

Please make sure that Docker has been installed on your local machine.

  1. Run all services in dev mode:
yarn start-dev

Or run specific service you need:

  • Aggregator: yarn start-aggregator:dev
  • API: yarn start-api:dev
  • Notifier: yarn start-notifier:dev

Migrations

Database migration workflow

  1. Change entity definition
  • If creating new entity, make sure it's specified in ormconfig.js
  1. Generate migration via:
  • yarn migration:generate
  • node -r ts-node/register -r tsconfig-paths/register ./node_modules/typeorm/cli.js migration:generate -n <MigrationName>
  1. Review generated migration & fix migration code style & lint warnings
  2. Run new migrations via: yarn migration:run
  3. If something went wrong, revert the last migration via: yarn migration:revert
  4. Commit changes

OR

You can sync database manually without running migration (NOT RECOMMENDED):

yarn schema:sync

Before syncing schema, a review of SQL queries to be executed is highly RECOMMENDED:

yarn schema:log

dao-api-gateway's People

Contributors

vhorin-mp avatar okalenyk avatar romasha2010 avatar andkom avatar volodymyr-iliashchenko avatar karpovdmitryod avatar roman-ponomarenko avatar dkrasovsky1 avatar karpovdmitry avatar vhorin-magicpowered avatar izek avatar verzuol1 avatar

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.