Skip to main content

Service

Repository: https://github.com/NaikAayush/shiro-storage/tree/main/service

The most important component.

Why?

This is the service which reads events on the chain and actually uploads files.

Pre-requisites

  • NodeJS v18
  • yarn

Set up

Install dependencies

yarn

Set up Redis

Run redis on the same instance/server as the API. Change password in redis-conf/redis.conf if needed.

cd redis-setup
docker-compose up -d
cd ..

See its README for more details.

Create a .env file

PORT=3000
QUICKNODE_URL=<URL of your ETH node - could be infura, quicknode, etc.>
CONTRACT_ADDRESS=<ShiroStore contract address>
IPFS_GATEWAY_URL=https://<Domain of IPFS deployment>/api/v0
WEB3STORAGE_TOKEN=<If using web3.storage, provide API Token here>
SENDGRID_API_KEY=<for sending emails>
REDIS_PASSWORD=<redis password. default: LongRedisPassword>

Dev server

yarn start:dev

Production deployment

systemd unit file

Script (name it start.sh, change HOME and nvm stuff if necessary):

#!/bin/bash

set -euxo pipefail

export HOME="/root"

export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # This loads nvm

SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )

cd "$SCRIPT_DIR"

yarn build

yarn start:prod

nginx config

server {
server_name <your domain>;

location / {
proxy_pass http://127.0.0.1:3000;
}
}

certbot can then be used to set up SSL/TLS for HTTPS.