Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
FROM node:14
WORKDIR /usr/src/app
RUN apt-get update
RUN apt-get -y install nodejs
RUN npm install -g npm
EXPOSE 6379
COPY package*.json ./
RUN npm install
COPY . .
CMD [ "node", "index.js" ]
6 changes: 1 addition & 5 deletions blockchain.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,7 @@ const dns = require('dns');
const https = require('https');
const fetch = require('node-fetch');
const Web3 = require('web3');
const {polygonVigilKey, ethereumHost} = require('./constants.js');

let config = require('fs').existsSync('./config.json') ? require('./config.json') : null;

const infuraProjectId = process.env.infuraProjectId || config.infuraProjectId;
const {polygonVigilKey, ethereumHost, infuraProjectId} = require('./environment.js');

let addresses,
abis,
Expand Down
9 changes: 1 addition & 8 deletions constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,11 +55,8 @@ const redisPrefixes = (() => {
return result;
})();
const nftIndexName = 'nftIdx';
const polygonVigilKey = `1bdde9289621d9d420488a9804254f4a958e128b`;
const ethereumHost = 'ethereum.exokit.org';
const storageHost = 'https://ipfs.exokit.org';
const appPreviewHost = `https://app.webaverse.com/preview.html`;
const mainnetSignatureMessage = `Connecting mainnet address.`;

module.exports = {
accountKeys,
nftKeys,
Expand All @@ -68,9 +65,5 @@ module.exports = {
tableNames,
redisPrefixes,
nftIndexName,
polygonVigilKey,
ethereumHost,
storageHost,
appPreviewHost,
mainnetSignatureMessage,
};
23 changes: 23 additions & 0 deletions environment.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
require('dotenv').config();

const fs = require('fs');

const config = fs.existsSync(__dirname + '/config.json') ? require('./config.json') : null;

const redisKey = (config && config.redisKey) ?? process.env.REDIS_KEY ?? "default";
const polygonVigilKey = (config && config.polygonVigilKey) ?? process.env.POLYGON_VIGIL_KEY ?? `1bdde9289621d9d420488a9804254f4a958e128b`;
const infuraProjectId = (config && config.infuraProjectId) ?? process.env.infuraProjectId;
const ethereumHost = (config && config.ethereumHost) ?? process.env.ETHEREUM_HOST ?? 'ethereum.exokit.org';
const storageHost = (config && config.storageHost) ?? process.env.STORAGE_HOST ?? 'https://ipfs.exokit.org';
const appPreviewHost = (config && config.appPreviewHost) ?? process.env.APP_PREVIEW_HOST ?? `https://app.webaverse.com/preview.html`;

if(!redisKey) console.warn("Environment vars not set successfully, do you have config.json or env vars set up?");

module.exports = {
redisKey,
polygonVigilKey,
infuraProjectId,
ethereumHost,
storageHost,
appPreviewHost
}
2 changes: 1 addition & 1 deletion index.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
const fs = require('fs');
const child_process = require('child_process');
const {initCaches} = require('./cache.js');
const {redisKey} = require('./config.json');
const {redisKey} = require('./environment.js');

let redisConfTxt = fs.readFileSync('./redis.conf.template', 'utf8');
redisConfTxt = redisConfTxt.replace(/# requirepass foobared/, `requirepass ${redisKey}`);
Expand Down
Loading