This repository contains source code for POA APIs.
This repository is configured to run with npm
.
- Node.js v18.16.0 or higher
- npm v8.4.0 or higher
- Mysql database
- SMTP mail server
First setup environment variables as described below then run:
npm install
npm run dev
Route | Description | Authentication required |
---|---|---|
POST /login |
Admin wallet login | false |
GET/PUT/POST/DELETE /poap-drops |
CRUD endpoints for POA drops | true |
GET /nft-collections |
Endpoint to get collections from Apillon platform | true |
GET /poap-drops/:id/drop-reservation-token |
Endpoint to generate jwt for reservation (qr code) | true |
POST /poap-drops/:id/reserve-drop |
Endpoint to reserve nft drop. User recieves email with instructions for mint | true (token from email) |
POST /claim |
Endpoint for claim - Mint NFT to specified wallet address | true (token from email) |
For local development and running app you will need to configure some environment variables. List of all supported vars can be found in /src/config/env.ts
.
For local development you should create .env
file. To run this app in Docker, you can create .env.deploy
and .env.sql.deploy
and use provided docker-compose.yml
For running locally, create new .env
file in project root folder (backend/
) and set at least all the variables (probably with different values) as in .env.deploy
file described bellow.
For running a docker image with docker-compose.yml
you should create .env.deploy
file like this example:
MYSQL_HOST: mysql # DB host (container name or ip/url)
MYSQL_DB: poa
MYSQL_USER: root
MYSQL_PASSWORD: Pa55worD?! # set your DB password (same as in .env.sql.deploy)
APP_URL: 'http://your-custom-url.com' # set URL of your frontend application
ADMIN_WALLET: # your EVM wallet address
# Apillon configuration
# Create (free) account at https://apillon.io to and setup API key and NFT collection
APILLON_KEY: # Apillon api key
APILLON_SECRET: # Apillon api key secret
# Your email server configuration
SMTP_HOST:
SMTP_PORT: '465'
SMTP_USERNAME:
SMTP_PASSWORD:
SMTP_EMAIL_FROM:
SMTP_NAME_FROM: 'NFT Airdrop'
# API configuration (you can just live it as it is or appropriate fix dockerfile and compose)
API_HOST: 0.0.0.0
API_PORT: 3000
For running a mysql docker image with docker-compose.yml
you should create .env.sql.deploy
file like this:
MYSQL_ROOT_PASSWORD: Pa55worD?! # set your DB password (same as in .env.deploy)
MYSQL_DATABASE: poa
Build docker image with script ./build-image.sh
script or by running docker build command, for example:
docker build -t ps-poa .
docker tag ps-poa ps-poa:latest
If you correctly setup .env files, you can run app in docker by running
docker compose up -d
In this prebuilt solution, we have limit our automated tests to basic end-to-end tests. Default testing framework for this project is Jest. Test are written in tests
directory.
For running tests, check if all environment variables with suffix _TEST
are correctly set. If running locally, variables should be set in your .env
file in root folder.
# TEST config
MYSQL_HOST_TEST: 127.0.0.1
MYSQL_DB_TEST: Poap_test
MYSQL_USER_TEST:
MYSQL_PASSWORD_TEST:
MYSQL_POOL_TEST: 20
npm run test
To run single test
npm run test -- <search pattern>
note the blank space after
--
Search pattern is used to find file with test. You may use filename or part of filename, for example login.test