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

Optimized server #1

Merged
merged 1 commit into from Mar 14, 2018

Conversation

Projects
None yet
2 participants
@franciscop
Contributor

franciscop commented Mar 7, 2018

Hi Blake, I just found out your blog post/tutorial and I think it's the first tutorial for server.js I've seen in the wild! Thank you so much!

server.js already includes static by default and the path can be defined through the option public, so the final server is only 1 line long as you can see in this PR!

require('server')({ public: '.' });

The documentation was way worse back then but I'm improving it as much as possible.

For security reasons I would recommend making the public folder a subfolder. The most common one in Node.js and default in server is ./public, so you wouldn't even need that configuration if you include your public assets in a public folder:

require('server')();

Would be awesome if you could add a small note in the post so anyone who finds it knows that server.js includes static and you don't need to include it manually, but it's totally up to you of course.

Did you continue using server.js? What are the issues that you found? Can I help you with anything?

Best,
Francisco

@BlakeSimpson

This comment has been minimized.

Owner

BlakeSimpson commented Mar 14, 2018

@franciscop Thank you for this information! I will update the article now with this highly simplified approach.

I honestly do not work on node servers all that often. I sometimes need a small proxy or static server to help with development and since even express can seem a bit complex I found your simple API in server.js refreshing.

I like your examples section on the website. It would be great to see some examples on how to do a proxy as well, as I assume that is quite a common use case.

@BlakeSimpson BlakeSimpson merged commit ebc9e3d into BlakeSimpson:master Mar 14, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment