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
- π About the Project
- π Arch Map
- π Built With
- π Live OpenAPI Docs
- π» Getting Started
- π Testing
- π€ Contributing
- βοΈ Show your support
- βFAQ
- π License
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.
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.
Framework
Language
Data Store
Request Library
Scheduling
Validation
Environment Configuration
Code Quality
Containerization
API Documentation
- 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
To get a local copy up and running, follow these steps.
In order to run this project you need:
Clone this repository to your desired folder:
Example commands:
git clone [email protected]:AmplicaLabs/account-service.git
cd account-service
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.
-
Copy the template values into the .env files.
cp env.template .env
-
Replace template values with values appropriate to your environment.
Install NPM Dependencies:
npm install
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
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
make test-e2e
This will run the tests in apps/api/test
folder.
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.
You may also view and manage the application's queue at http://localhost:3000/queues.
npm run lint
npm run format
-
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.
-
Follow step 1 from the Development Environment section above to set up the redis and frequency containers.
-
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. -
Set breakpoints in the code and debug your code.
-
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.
-
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.
Contributions, issues, and feature requests are welcome!
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.
-
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.
This project is Apache 2.0 licensed.