"But I just want so serve up some files... why all of this setup". Have you ever said that to yourself.
Worry no more - static-now is here to help you. With a single line your web server is ready to roll, and you can focus on the static files instead.
This will start a Koa web server on port 3000 and start listening.
You can do it on two lines also for readability
var staticnow = ;;
Starting the application
Start you application with the harmony features enabled:
node --harmony app.js
Or if you're using io.js leave out the flag:
Here's a package.json node ready for you so that you can use
"scripts":"start": "node --harmony app.js"
There's just a few configuration options that you can use to control the behaviour of static-now.
var options = directory : __dirname ;options;
By default the directory that node is started in is used. Meaning if you go
npm --harmony app.js in
/Volumes/Users/marcus/demo the files in that directory will be exposed via the web server.
var options = portnumber : 3456 ;options;
By default port 3000 is used, meaning that your web server is started at http://localhost:3000.
For hosting in Heroku, or other platform as a service providers, you can use a process parameter to get the correct port. Like so:
var options = portnumber : processenvPORT ;options;
var options = autostart : false ;var app = options;
You don't have to start the application right away, if you don't have too. The static-now function returns the Koa application so that you can start it yourself, when appropriate.
A good time when this can be handy is for testing, when usually the testing framework is starting the application up. Like this, using supertest
var supertest = ;var staticNow = ;;
var options = log : true ;var app = options;
static-now spits out some log messages showing you the current configuration etc. You can turn that off or on using the log option.