Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor StaticServer constructor #32

Closed
rangav opened this issue Feb 1, 2018 · 1 comment
Closed

Refactor StaticServer constructor #32

rangav opened this issue Feb 1, 2018 · 1 comment

Comments

@rangav
Copy link

rangav commented Feb 1, 2018

Hi

This is a suggestion,
Too many conditions check in constructor, my suggestion below

let server = new StaticServer({port: 8080, localOnly : true, keepAlive : true });

class StaticServer {
          constructor(opts) {
                       if(opts)
                        {
				this.port = `${opts.port}` || PORT;
				this.root = opts.root || ROOT;
				this.localOnly = opts.localOnly || false;
				this.keepAlive = opts.keepAlive || false;
			 }
			else{
				this.port = PORT;
				this.root = ROOT;
				this.localOnly = false;
				this.keepAlive = false;
                   }
             }

....
}

let me know your feedback

@fchasen
Copy link
Contributor

fchasen commented Mar 20, 2018

Agreed this could be simpler, but don't think it is worth breaking changes.

@fchasen fchasen closed this as completed Mar 20, 2018
smellman pushed a commit to smellman/react-native-static-server that referenced this issue Sep 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants