This repository contains the code for the Token API.
The code is based on this boilerplate template.
For now, the API only supports the following endpoints:
<endpoint>/v1/status<endpoint>/v1/:network/token/stats
The :network parameter can be either pendulum or amplitude.
The API uses a cache server to store the token stats.
The cache server is a memcached instance.
The server address is defined in the CACHE_URI environment variable and the lifetime of cache entries is defined in
the CACHE_LIFETIME_SECONDS environment variable.
Each network has a different cache key, thus the stats for each network are stored separately.
The API uses a rate limiter to prevent abuse. The rate limiter is based on the express-rate-limit package. It can be configured using the following environment variables. For more details check the respective section below.
yarncp .env.example .envyarn devyarn start# lint code with ESLint
yarn lint
# try to fix ESLint errors
yarn lint:fix
# lint and watch for changes
yarn lint:watch# show logs in production
pm2 logs# generate and open api documentation
yarn docsNODE_ENV- The environment the application is running in, default isproductionPORT- The port the HTTP server will listen on, default is3000AMPLITUDE_WSS- The Amplitude Websocket URL, default iswss://rpc-amplitude.pendulumchain.techPENDULUM_WSS- The Pendulum Websocket URL, default iswss://rpc-pendulum.prd.pendulumchain.techCACHE_URI- The URI of the cache server instance, default ishttp://localhost:11211CACHE_LIFETIME_SECONDS- The lifetime of a cache entry in seconds, default is600secondsRATE_LIMIT_MAX_REQUESTS- The maximum number of requests per IP address, default is100RATE_LIMIT_WINDOW_MINUTES- The time window in minutes for the rate limit, default is15minutesRATE_LIMIT_NUMBER_OF_PROXIES- The number of proxies between server and user, default is1