From c7cceef8bef70f61e7ca19a7317eb1f0247820ce Mon Sep 17 00:00:00 2001 From: Keno Dressel Date: Tue, 23 Apr 2024 12:04:44 +0200 Subject: [PATCH] fix: allows local env to be used for dev --- .env.example | 24 ++++++++++++++++++++++++ README.md | 15 ++++++++++++--- bin/www.js | 3 +++ package-lock.json | 17 +++++++++++++++++ package.json | 2 ++ 5 files changed, 58 insertions(+), 3 deletions(-) create mode 100644 .env.example diff --git a/.env.example b/.env.example new file mode 100644 index 00000000..ac4c92d4 --- /dev/null +++ b/.env.example @@ -0,0 +1,24 @@ +REDIS_HOST=localhost +REDIS_PORT=6379 +NODE_URL=https://mainnet.aeternity.io +COMPILER_URL=https://latest.compiler.aepps.com +CONTRACT_V1_ADDRESS=ct_2AfnEfCSZCTEkxL5Yoi4Yfq6fF7YapHRaFKDJK3THMXMBspp5z +CONTRACT_V3_ADDRESS=ct_2Hyt9ZxzXra5NAzhePkRsDPDWppoatVD7CtHnUoHVbuehwR8Nb +TOKEN_REGISTRY_ADDRESS=ct_2n76BQCN3zNEjuEvHFNZtgyWPc5zizy47wNrUT3RHP2MrPKhbq +ORACLE_CONTRACT_ADDRESS=ct_7wqP18AHzyoqymwGaqQp8G2UpzBCggYiq7CZdJiB71VUsLpR4 +MIDDLEWARE_URL=https://mainnet.aeternity.io/mdw +IPFS_URL=http://localhost:5001 +PUBLIC_KEY=ak_yrVCHP97UWfCRGMCaojBjdSKuXD3yyC8NkzkReURd4t3jbCQW # use an account with some tokens here +PRIVATE_KEY=f38eecf78a521fcbf34d253b6681f69e0f64d99526d63e18f205e03cf30dd1248117982ba9504170f1f40c66c137c1823244dc7795950a85807793626e69ebce +AUTHENTICATION_USER=user # used for blacklisting & flagging ui, replace with your own credentials +AUTHENTICATION_PASSWORD=password # used for blacklisting & flagging ui, replace with your own credentials +NODE_ENV=production +WEBSOCKET_URL=wss://mainnet.aeternity.io/mdw/websocket +ORACLE_GETTER_ADDRESS=ct_anbp2U5VUsF6PkrX1ER1hSqj76Krpvqy97c5JBLmubBecCWui +CONTRACT_V1_GETTER_ADDRESS=ct_NR7Bd7j5LRdzvKZmrMagMkfxzG8ZPWseKQkdwWootpq4kAJY2 +CONTRACT_V3_GETTER_ADDRESS=ct_2NdZ6PX9tZHWFhgcoYjthYNFF15qxjDwFSsNXRPeajEWazxkTo +# all optional +POSTGRES_PASSWORD=postgres # replace with your own credentials +POSTGRES_USER=postgres # replace with your own credentials +POSTGRES_DB=superhero +POSTGRES_HOST=localhost diff --git a/README.md b/README.md index 7ac59309..8d5bd32f 100644 --- a/README.md +++ b/README.md @@ -26,6 +26,17 @@ docker-compose up -d npm i ``` +#### Start a database & redis +```bash +docker run --rm --name ipfs -p 5001:5001 -d ipfs/go-ipfs +docker run --name superhero-postgres -e POSTGRES_PASSWORD=postgres -e POSTGRES_USER=postgres -e POSTGRES_DB=superhero -p5432:5432 -d postgres +``` + +#### Copy Env +```bash +cp .env.example .env +``` + #### Create Database ```bash @@ -33,8 +44,6 @@ npm run db:create ``` #### Start server -In order to run the server, an **ipfs, redis & the above mentioned env** are required - ```bash -node bin/www.js +npm start ``` diff --git a/bin/www.js b/bin/www.js index bb7c2242..a6ef7506 100644 --- a/bin/www.js +++ b/bin/www.js @@ -1,4 +1,7 @@ #!/usr/bin/env node +// Load environment variables +require('dotenv').config(); + const http = require('http'); const Sentry = require('@sentry/node'); diff --git a/package-lock.json b/package-lock.json index 8b4a6a78..39b12c15 100644 --- a/package-lock.json +++ b/package-lock.json @@ -18,6 +18,7 @@ "bignumber.js": "^9.0.1", "cld": "^2.7.0", "cors": "^2.8.5", + "dotenv": "^16.4.5", "esm": "^3.2.25", "express": "^4.17.1", "express-async-errors": "^3.1.1", @@ -3416,6 +3417,17 @@ "node": ">=8" } }, + "node_modules/dotenv": { + "version": "16.4.5", + "resolved": "https://registry.npmjs.org/dotenv/-/dotenv-16.4.5.tgz", + "integrity": "sha512-ZmdL2rui+eB2YwhsWzjInR8LldtZHGDoQ1ugH85ppHKwpUHL7j7rN0Ti9NCnGiQbhaZ11FpR+7ao1dNsmduNUg==", + "engines": { + "node": ">=12" + }, + "funding": { + "url": "https://dotenvx.com" + } + }, "node_modules/dottie": { "version": "2.0.2", "resolved": "https://registry.npmjs.org/dottie/-/dottie-2.0.2.tgz", @@ -14855,6 +14867,11 @@ "is-obj": "^2.0.0" } }, + "dotenv": { + "version": "16.4.5", + "resolved": "https://registry.npmjs.org/dotenv/-/dotenv-16.4.5.tgz", + "integrity": "sha512-ZmdL2rui+eB2YwhsWzjInR8LldtZHGDoQ1ugH85ppHKwpUHL7j7rN0Ti9NCnGiQbhaZ11FpR+7ao1dNsmduNUg==" + }, "dottie": { "version": "2.0.2", "resolved": "https://registry.npmjs.org/dottie/-/dottie-2.0.2.tgz", diff --git a/package.json b/package.json index ee515b9b..2a26d37b 100644 --- a/package.json +++ b/package.json @@ -5,6 +5,7 @@ "main": "bin/www.js", "prepare": "husky install", "scripts": { + "start": "node bin/www.js", "test": "mocha modules/**/tests/*.js --exit", "benchmark": "node benchmark.js", "db:create": "npx sequelize-cli --config config/config.js --env development db:migrate", @@ -37,6 +38,7 @@ "bignumber.js": "^9.0.1", "cld": "^2.7.0", "cors": "^2.8.5", + "dotenv": "^16.4.5", "esm": "^3.2.25", "express": "^4.17.1", "express-async-errors": "^3.1.1",