The core API that powers all of MetaFab's services.
If you just want to use MetaFab, you can use our hosted version here: https://docs.trymetafab.com/docs
MetaFab currently runs on top of AWS. The stack is primarily node.js, prisma (MySQL orm), Redis, ethers.js
Follow these steps to get the API up and running locally
- Use
nvm
or equivalent to install Node version 16.0.0+ locally. git clone --recurse-submodules
this repo.cd
into the repo folder, runnpm install
- Follow this guide to install Redis locally if you don't already have it: https://redis.io/docs/getting-started/installation/
- Install MySQL 5.7 locally, we use Amazon Aurora in production which uses MySQL 5.7. Guide can be found here: https://dev.mysql.com/doc/mysql-installation-excerpt/5.7/en/
- Make sure your local MySQL server is running,
cd
into the root folder of our API and runnpx prisma migrate dev
to create a local MetaFab database & all necessary tables. - Create a local
.env
file. You can just copy.env.sample
for local development quickstart.
- In a terminal window, start a local redis server by running
redis-server
. - In another terminal window, start a local ethereum environment by
cd
into the root folder of our API repo and runningnpx hardhat node
- In another terminal window, start the api by
cd
into the root folder of our API repo and runningnpm run dev
Once you have an environment up and running locally, you can run the entire test suite located in test/
by cd
into the root folder of our API repo and running npm test
Any commits merged into the master
branch will automatically trigger a deployment to production. The master branch is guarded and can only be committed directly to, or have PR's approved by a specific set of individuals within the team.
It is expected that any typical feature development is done on it's own branch and merged into master once completed and approved.
MetaFab's development pattern has been setup such that each API endpoint within the codebase that is intended to be publicly exposed for developer consumption is documented according to the OpenAPI 3.0 spec. You can see examples of this by looking at nearly every route file in the routes/
folder.
This pattern allows us to retain clear endpoint purpose documentation within our own internal development environment, quality control and check that API endpoints are build to meet their intended purpose, generate OpenAPI 3.0 spec and auto update our docs.trymetafab.com website, and auto-generate SDKs for all our supported platforms.
The OpenAPI spec file is saved to the openapi/spec/
directory. You can generate the OpenAPI spec at any time using npm run generate-openapi-spec
You can generate an updated version matching the latest API spec using npm run generate-openapi-sdks
. This will automatically generate SDKs for all of our supported platforms to the openapi/sdks/
directory for each respective platform.