Specify port in cli
This commit is contained in:
parent
b5c8775c81
commit
f0ae3da8f1
3 changed files with 8 additions and 3 deletions
|
@ -15,6 +15,7 @@ Usage:
|
|||
Options:
|
||||
-h --help Show this screen.
|
||||
--version Show version.
|
||||
-p <port> --port=<port> Port to listen on.
|
||||
-b <auth> --basic-auth=<auth> Enable basic-auth.
|
||||
-i <ips> --ips=<ips> Allowed IP addresses.
|
||||
-l --list-dir List Directory.
|
||||
|
@ -27,6 +28,7 @@ export default function getArgs() : Options {
|
|||
help: true
|
||||
});
|
||||
return {
|
||||
port: rawArgs['--port'] || process.env.PORT || 5000,
|
||||
allowed_ips: rawArgs['--ips'] ? rawArgs['--ips'].split(',') : [],
|
||||
basicAuth: rawArgs['--basic-auth'] ? rawArgs['--basic-auth'].split(':') : [],
|
||||
dirList: rawArgs['--list-dir'],
|
||||
|
|
|
@ -2,9 +2,11 @@ import { docopt } from 'docopt';
|
|||
import createServer from './server';
|
||||
import getArgs from './cli';
|
||||
|
||||
console.log("Starting Server...")
|
||||
const app = createServer(getArgs());
|
||||
console.log("Starting Server...");
|
||||
|
||||
const server = app.listen(5000, function () {
|
||||
const ARGS = getArgs();
|
||||
const app = createServer(ARGS);
|
||||
|
||||
const server = app.listen(ARGS.port, function () {
|
||||
console.log("Server started on port " + server.address().port);
|
||||
});
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
|
||||
export interface Options {
|
||||
port: number;
|
||||
allowed_ips: string[];
|
||||
basicAuth: string[];
|
||||
dirList: boolean;
|
||||
|
|
Reference in a new issue