🔐
Trust Enterprises
  • Getting Started
  • Intro video course
    • Introduction of the Trust Enterprises project [2:16]
    • Deployment of your first Serverless client [6:29]
    • Using Postman with the Trust Enterprises API [6:33]
    • Installation of the Trust Enterprises Laravel package [7:51]
    • Basic interaction with your client with Laravel. [10:28]
  • Deployment
    • Vercel
    • Environment Variables
    • Github Actions
  • REST API
    • Overview
    • Inscriptions
      • Deploy an Inscription
      • Mint an Inscription
      • Burn an Inscription
      • Transfer an Inscription
    • NFT Ecosystem
      • Create an NFT Collection
      • Generate Metadata
      • Mint an NFT
      • Transfer an NFT
      • Claiming NFTs through Passes
    • Accounts
    • Tokens
      • Create a token
      • Bequesting a token
      • Token Holdings and Balance
    • Topics
      • Get topic info
      • Creating a new topic
      • Updating a topic
    • Consensus Messages
    • Balance
    • Status
    • Webhooks
  • The Laravel Client
    • Overview
    • Installation
    • Interacting with your client
    • Create a Marketplace
    • Manage your Inscription Flow
    • Checking account balances and sending tokens
  • Contributing
    • Local Development
      • Architecture Rationale
    • Contributing Guidelines
    • Changelog
  • Links
    • Github
    • Trust Enterprises
    • Postman Documentation
    • Hedera Network Status
    • Remote Software Development
Powered by GitBook
On this page

Was this helpful?

  1. Contributing
  2. Local Development

Architecture Rationale

The internal structure we used to build the API and why.

PreviousLocal DevelopmentNextContributing Guidelines

Last updated 4 years ago

Was this helpful?

The architecture is more or less custom as the API layer on a NextJS app is very thin, it focuses on using simple handlers for processing API requests.

All API requests hit the pages/api directory, are processed by a defined set of middleware, then if successfully forwarded to a given handler.

You can consider app/handlers to effectively be invokable single function controllers.

The validation for a given handler is expected to be tightly coupled to the code, as it is simpler to test a handler in isolation.

As the Hedera Hashgraph costs a small amount of real money, we have created a mock that is injected into the handlers during the basic set of tests to prove additional logic for the API query and body parameters.

All other items that validate and inject into a handler do so at the API route layer. We use a process function to chain a list of middleware, authentication validation, and context injection before hitting in the handler. Providing a higher degree of flexible testability.

Due to the constraints of Vercel only providing a maximum of 12 unique routes for a free account, this can be slightly overcome through leveraging a routing to handler approach.

The topic handler pages/api/consensus/topic/[id].js provides additional insight into how to wrap a single route to manage a given resource consisting of different handlers.

Thank you to for your insight on handling injecting additional functionality as context for a given handler.

James Wrightson