metropolis
leverages two separate servers: an Express.js API server, and a React.js frontend server.
The responsibility of the Express.js API server is to provide the backend connectivity to make calls to the Colony Network and general-store
to return data to the React.js frontend server.
The Express.js API server runs on port 3001 while the React.js frontend server runs on port 3000.
Developers can leverage metropolis
to make queries and fetch data about the Colony Network by hitting the API endpoint.
Base Url: http://18.220.184.249:3001/api/
The following endpoints are supported...
/network/count/colony
/network/count/domain
/network/count/skill
/network/count/task
/token/colonyId/:colonyId
/colony/id/:address
/colonies/:pageId
/domains/:pageId
/skills/:pageId
/tasks/:pageId
/tasks/ethereum/:colonyId/:startId/:endId?
/domains/ethereum/:colonyId/:startId/:endId?
/colonies/ethereum/:startId/:endId?
/skills/ethereum/:startId/:endId?
/colony/:id
/domain/:colonyId/:id
/skill/:id
/task/:colonyId/:id
We leverage two shell scripts scheduled to run every minute to ensure that our web application components (Express.js server and React.js frontend server) are always available. These shell scripts check to see if the processes are running, and will start them up (restart) if the processes are not running.
#!/bin/sh
if [[ $(pgrep -f dist/server.js) ]]; then
echo "Express API server is already running!";
else
echo "Starting Express API server...";
nohup node $HOME/ColonyExplorer/metropolis/dist/server.js > /dev/null &
fi
#!/bin/sh
if [[ $(pgrep -f node_modules/react-scripts/scripts/start.js) ]]; then
echo "React server is already running!";
else
echo "Starting React server...";
nohup yarn start > /dev/null &
fi