Jump-start your front-end server. Bundles and configures the boilerplate of a Koa app. Originally inspired by tj/serve.
Using the CLI:
npm install -g roo
Using the API:
npm install roo
- Flexible: Javascript & CLI API
- Deployable: Ready to be deployed to Dokku or Heroku
- Composable: Mount Koa servers within or mount within other Koa servers.
- Higher-level: Templating, Routing & Duo baked-in
API:
Roo(__dirname)
.auth('username', 'password')
.get('/', 'index.jade')
.duo('*.{js,css}')
.exec('make build')
.mount('/api', api)
.compress()
.serve('build')
.cors()
.listen(4000);
CLI
$ roo -h
Usage: roo [options] [dir]
Options:
-h, --help output usage information
-V, --version output the version number
-a, --auth <user>:<pass> specify basic auth credentials
-p, --port <port> specify the port [process.env.PORT || 3000]
-f, --favicon <path> serve the given favicon
-d, --duo <path|glob> set a path or glob for duo [*.{css,js}]
-i, --index set the entry point for "/" [index.*]
-s, --static <dir> set a static path ["."]
-c, --cors allows cross origin access serving
-e --exec <cmd> execute command on each request
--no-dirs disable directory rendering
--no-compress disable compression
Initialize Roo
at the root
path. Defaults to .
.
Add a route to Roo
. Routing is powered by kr, so visit there for API details.
Additionally, you may pass a filepath
to handle
, which will render using consolidate.
roo
.get('/', 'index.jade')
.post('/signup', signup)
Set a favicon at path
Add basic auth with a user
and pass
.
Add route logging with an optional filter fn
.
roo.logger(function(ctx) {
return extname(ctx.url) ? false : true;
});
ctx
in this case is a "koa context".
Execute a command
every refresh
Pass additional middleware generator
's to Roo
.
Mount inside another app at path
.
app.use(roo.mount('/dashboard'));
Mount an app inside of Roo
at path
roo.mount('/dashboard', app);
Pass a file
or glob
expression to be compiled using duo.
Compress CSS and JS assets
Roo the entire directory using koa-serve-index
Add a static asset directory
to roo from
Enable CORS
on the roo. options
get passed directly to node-cors.
Start the server on port
. You may pass the environment variable PORT=8080
in to specify a port. Otherwise it defaults to 3000
if otherwise not specified.
- LiveReload support
- Tests would be nice
Roo is short for Kangaroo. I wrote this while visiting Australia for CampJS and I have Kangaroos on my mind.
Kangaroo Icon by Olivier Guin
(The MIT License)
Copyright (c) 2014 Matthew Mueller <matt@lapwinglabs.com>
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the 'Software'), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.