Skip to content
This repository has been archived by the owner on Jul 25, 2024. It is now read-only.

A Gateway microservice enabling easy interaction with DSNP accounts on Frequency

License

Notifications You must be signed in to change notification settings

ProjectLibertyLabs/account-service

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Repository Archived and Moved

This repository has been archived and its contents have been moved to a new location.

You can now find the account-service repository within the AmplicaLabs/gateway repository at the following path:

./services/account

For any future updates or contributions, please refer to the new location. Thank you!


Link to the new repository: AmplicaLabs/gateway

Account Service

πŸ“— Table of Contents

πŸ“– account-service

Account Service is a service enabling easy interaction with DSNP accounts on Frequency. Accounts can be defined as a user's handle and msaId.

Visit Key Features for more details on what Account Services does.

πŸ”­ Arch Maps

The account-service is a NestJS application that is split into two main parts: the API and the Worker.

The API is responsible for handling incoming HTTP requests and the Worker is responsible for processing jobs that require blockchain interaction.

Gateway Account Service

(back to top)

πŸ›  Built With

Tech Stack

Framework
Language
Testing Libraries
Linting
Data Store
Request Library
Scheduling
Validation
Environment Configuration
Code Quality
Containerization
API Documentation

Key Features

  • Account creation using SIWF
    • Includes behind the scenes delegation to the provider
  • Get User and Provider Account(s)
  • Handle (aka username) claiming
    • Create
    • Change
  • Keys Handling
    • Add keys to an account
    • Get keys
  • Get delegation info for an msaId
  • Easy integration with Web3 wallets

(back to top)

πŸš€ Live Docs

(back to top)

πŸ’» Getting Started

To get a local copy up and running, follow these steps.

Prerequisites

In order to run this project you need:

Setup

Clone this repository to your desired folder:

Example commands:

  git clone [email protected]:AmplicaLabs/account-service.git
  cd account-service

Environment Variables

Modify any environment variables in the .env file as needed. The complete set of environment variables is documented here, and a sample environment file is provided here.

  1. Copy the template values into the .env files.

    cp env.template .env
  2. Replace template values with values appropriate to your environment.

Install

Install NPM Dependencies:

  npm install

Usage

Note: using docker compose file to start the services. This will start the services in development mode.

The following command will start all of the necessary containers for the account service to run in development mode.

make restart-chain-docker

In order to run the account-service in development mode without containers, you can use the following commands:

1. Start the Redis server container and the Frequency container. You can view the logs with your Docker setup

make restart-local-dev

Once Frequency is up, you can monitor the transactions on the blockchain.

2. Follow the instructions in the terminal to start the local apps. Start the mock webhook server by running the following command in another terminal or in the background

make mock-webhook

3. Start the Api and Worker.

Option 1: In a new terminal window, start the account-service api app. Logs will be displayed in the terminal for easy reference.

npm run start:api:debug

In another terminal window, start the account-service worker app.

npm run start:worker:debug

-- or --

Option 2: Run the following command to start the account service api and worker containers. This will start the account service api and worker in development mode.

docker-compose up -d api worker

4. Check the job in BullUI, to monitor job progress based on defined tests

πŸ“‹ Testing

Run the tests

make test-e2e

This will run the tests in apps/api/test folder.

Check e2e test file for more details on the test

Swagger UI

Check out the Swagger UI hosted on the app instance at http://localhost:3000/api/docs/swagger to view the API documentation and submit requests to the service.

Queue Management

You may also view and manage the application's queue at http://localhost:3000/queues.

Linting

  npm run lint

Auto-format

  npm run format

Debugging

  • Docker to stop containers, networks, volumes, and images created by docker-compose up run...

      docker-compose down
  • You may have to go to your Docker Desktop app and manually remove containers.

Using the Debugger with VSCode

  1. Follow step 1 from the Development Environment section above to set up the redis and frequency containers.

  2. Use the debug panel and start the Debug Api (NestJS via ts-node) configuration, if you wish to debug the api.

    Use the debug panel and start the Debug Worker (NestJS via ts-node) configuration, if you wish to debug the worker.

  3. Set breakpoints in the code and debug your code.

  4. Monitor the service worker jobs in BullUI.

    Any API functions that require an extrinsic to be submitted to the blockchain will be queued here. The queue will manage the amount of capacity this service is allowed to use.

    Reference the Frequency Docs for more information about extrinsics and capacity.

  5. Use Swagger to test the API.

Note: Reference .vscode/launch.json for more details on the debug configurations and apply the concepts to your preferred debugger.

(back to top)

🀝 Contributing

Contributions, issues, and feature requests are welcome!

(back to top)

⭐️ Show your support

If you would like to explore contributing bug fixes or enhancements, issues with the label good-first-issue can be a good place to start.

(back to top)

❓FAQ

  • Can I use this service in my production social app?

    • Yes. All the Gateway Services are intended to be ready-to-use out of the box as part of the fabric of your own social media app using DSNP on Frequency.
  • I'm building the next Facebook, it's going to be huge! Will account-service scale?

    • Gateway Services are designed to support the scale of a small-to-medium-sized social app. For larger use cases, you would probably want to build your own services.

(back to top)

πŸ“ License

This project is Apache 2.0 licensed.

(back to top)