Skip to content

Commit 041f6fa

Browse files
committed
Added host option
1 parent aec37ee commit 041f6fa

File tree

2 files changed

+15
-6
lines changed

2 files changed

+15
-6
lines changed

README.md

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,9 @@ DYNAMO_ENDPOINT=http://localhost:8000 dynamodb-admin
2121
Options:
2222
- --open / -o - opens server URL in a default browser on start
2323
- --port PORT / -p PORT - Port to run on (default: 8001)
24+
- --host HOST / -h HOST - Host to run on (default: localhost)
2425

25-
You can also specify port to run on by setting environment variable `PORT` to given number. This will override value specified on the command line. This is legacy way to specify PORT.
26+
You can specify host & port to run on by setting environment variables `HOST` and `PORT` respectively. This will override value specified on the command line. This is legacy way to specify the HOST & PORT.
2627

2728
If you use a local dynamodb that cares about credentials, you can configure them by using the following environment variables `AWS_REGION` `AWS_ACCESS_KEY_ID` `AWS_SECRET_ACCESS_KEY`
2829

@@ -43,11 +44,12 @@ const dynClient = new AWS.DynamoDB.DocumentClient({service: dynamodb});
4344

4445
const app = createServer(dynamodb, dynClient);
4546

47+
const host = 'localhost';
4648
const port = 8001;
47-
const server = app.listen(port);
49+
const server = app.listen(port, host);
4850
server.on('listening', () => {
4951
const address = server.address();
50-
console.log(` listening on http://0.0.0.0:${address.port}`);
52+
console.log(` listening on http://${address.address}:${address.port}`);
5153
});
5254
```
5355

bin/dynamodb-admin.js

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,12 @@ parser.add_argument('-o', '--open', {
2626
help: 'Open server URL in default browser on start',
2727
})
2828

29+
parser.add_argument('-H', '--host', {
30+
type: 'str',
31+
default: 'localhost',
32+
help: 'Host to run on (default: localhost)',
33+
})
34+
2935
parser.add_argument('-p', '--port', {
3036
type: 'int',
3137
default: 8001,
@@ -35,12 +41,13 @@ parser.add_argument('-p', '--port', {
3541
const args = parser.parse_args()
3642

3743
const app = createServer()
44+
const host = process.env.HOST || args.host
3845
const port = process.env.PORT || args.port
39-
const server = app.listen(port)
46+
const server = app.listen(port, host)
4047
server.on('listening', () => {
4148
const address = server.address()
42-
const url = `http://localhost:${address.port}`
43-
console.log(` dynamodb-admin listening on ${url} (alternatively http://0.0.0.0:${address.port})`)
49+
const url = `http://${address.address}:${address.port}`
50+
console.log(` dynamodb-admin listening on ${url})`)
4451

4552
if (args.open) {
4653
open(url)

0 commit comments

Comments
 (0)