Skip to content

Commit

Permalink
Merge pull request #3 from vulcanize/server-host
Browse files Browse the repository at this point in the history
add environment variable HOST
  • Loading branch information
ramilexe committed Jun 17, 2021
2 parents 3a574e3 + 2b5d4f1 commit d9bde72
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 4 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
To start the application, you need to enter the command `npm start`

__Environment variables__:
- `HOST` - network listening address
- `PORT` - network listening port
- `GETH` - address of geth rpc server
- `ACCOUNTS` - list of private keys separated by commas
Expand Down
3 changes: 2 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ const fastify = require('fastify')({ logger: true });
const web3 = require('./src/web3');

const port = process.env.PORT || '3000';
const host = process.env.HOST || '127.0.0.1';
const geth = process.env.GETH || 'http://localhost:8545';
const accs = process.env.ACCOUNTS || '';

Expand All @@ -11,7 +12,7 @@ fastify.register(require('./src/deploy'));
fastify.register(require('./src/read'));
fastify.register(require('./src/send'));

fastify.listen(port, function (err, address) {
fastify.listen(port, host, function (err, address) {
if (err) {
fastify.log.error(err)
process.exit(1)
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
"scripts": {
"start": "node index.js",
"test": "npx mocha",
"test:start": "ACCOUNTS=\"0x321f89f3a648166df5af4dd2c808d91ba190b617ee181bc3e94ed1c08801b1ac,0x43332f8bd112b2ed44d97e791bb609ff6f0e04e984d6823360370b6c6285b213\" node index.js",
"test:ganache": "npx ganache-cli --account \"0x321f89f3a648166df5af4dd2c808d91ba190b617ee181bc3e94ed1c08801b1ac,1000000000000000000000\" --account \"0x43332f8bd112b2ed44d97e791bb609ff6f0e04e984d6823360370b6c6285b213,1000000000000000000000\""
"test:start": "PORT=8889 GETH=http://127.0.0.1:8888 ACCOUNTS=\"0x321f89f3a648166df5af4dd2c808d91ba190b617ee181bc3e94ed1c08801b1ac,0x43332f8bd112b2ed44d97e791bb609ff6f0e04e984d6823360370b6c6285b213\" node index.js",
"test:ganache": "npx ganache-cli -p 8888 --account \"0x321f89f3a648166df5af4dd2c808d91ba190b617ee181bc3e94ed1c08801b1ac,1000000000000000000000\" --account \"0x43332f8bd112b2ed44d97e791bb609ff6f0e04e984d6823360370b6c6285b213,1000000000000000000000\""
},
"repository": {
"type": "git",
Expand Down
1 change: 1 addition & 0 deletions src/deploy.js
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ async function handler(req, reply) {
reply.send({
uuid: memory.save({ address: re.contractAddress, bytecode, abi }),
address: re.contractAddress,
abi,
});
}

Expand Down
2 changes: 1 addition & 1 deletion test/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ const assert = require('assert');
const fetch = require('node-fetch');

async function post(method, data) {
const res = await fetch(`http://localhost:3000/${method}`, {
const res = await fetch(`http://localhost:8889/${method}`, {
method: 'POST',
headers: {
'Content-Type': 'application/json',
Expand Down

0 comments on commit d9bde72

Please sign in to comment.