Skip to content

Latest commit

 

History

History
192 lines (124 loc) · 5.13 KB

File metadata and controls

192 lines (124 loc) · 5.13 KB

Content Publisher Service

The Content Publisher Service is a crucial component of the Gateway suite, providing a familiar REST API for uploading content and publishing announcements to the Frequency blockchain. This document provides an overview of the service, its architecture, and guides for setup and usage.

📗 Table of Contents

📖 About the Project

The Content Publisher Service is part of the Gateway suite that provides a Web2-friendly interface for blockchain content operations. It handles all necessary blockchain interactions, allowing clients to use familiar REST API patterns for publishing and managing content on the Frequency chain.

🔍 Architecture Overview

The Content Publisher Service consists of two main components:

  1. API Controller: Handles incoming HTTP requests and enqueues content publishing tasks
  2. Worker Process: Processes queued tasks and interacts with the blockchain

The API and Worker processes communicate via a shared BullMQ message queue.

Content Publishing Service Architecture

🔑 Key Features

Content Management

  • Upload asset files: Handle file uploads to the system
  • Create broadcasts: Publish new posts to the network
  • Create replies: Respond to existing content
  • Create reactions: Add reactions to content
  • Update content: Modify existing content
  • Delete content: Remove content (via tombstones)
  • Update profiles: Manage user profile information

Development Features

  • Job management: Monitor and manage publishing jobs
  • Asset retrieval: Access stored assets
  • Test data: Generate sample announcement data

💻 Getting Started

This section guides you through setting up the Content Publisher Service for both development and deployment.

Prerequisites

Ensure you have the following installed:

Quick Start

  1. Clone the repository and navigate to the project directory:

    git clone https://github.com/ProjectLibertyLabs/gateway.git
    cd gateway
  2. Install dependencies:

    npm install
  3. Set up environment variables:

    cp env-files/content-publishing.template.env .env.content-publishing

    Configure the environment variables according to your needs.

  4. Start auxiliary services:

    docker compose up -d frequency redis ipfs
  5. Start the application services:

    API Service:

    npm run start:content-publishing-api:dev

    Worker Service:

    npm run start:content-publishing-worker:dev
  6. Set up with account data:

    make setup-account

Alternative: Docker Setup

  1. Run services using Docker:

    docker compose up -d frequency content-publishing-service-api content-publishing-service-worker
  2. Set up with account data:

    make setup-account

Verification

Docker Setup

Local Development Setup

🚀 API Documentation

🛠 Development

Testing

Run the test:

npm test:content-publishing

Run E2E tests:

npm run test:e2e:content-publishing

Linting and Formatting

Run linter:

npm run lint

Auto-format code:

npm run format

Built With

  • Server Framework: NestJS, Node.js, TypeScript
  • Data Store: Redis (ioredis)
  • Queue System: BullMQ
  • Blockchain Integration: Polkadot API, DSNP
  • Testing: Jest, Supertest
  • Documentation: Swagger
  • Containerization: Docker, Docker Compose

🤝 Contributing

We welcome contributions! Please check our Contributing Guidelines and open issues.

❓ FAQ

Q: Can I use this service in my production social app?

Yes, Gateway Services are designed to be ready-to-use out of the box as part of your own social media app using DSNP on Frequency.

📝 License

This project is licensed under the Apache 2.0 License.

(back to top)