Jump-start your front-end server. Bundles and configures the boilerplate of a Koa app.
Originally inspired by tj/serve. Then inspired by lapwinglabs/roo.
Similar to how Heroku ushers you towards the Twelve-Factor App, the goal of Yoo is to provide smart defaults for quickly building front-end servers, while keeping the library small and configurable.
As the server landscape changes, we'll be adding and removing features. We will increment the major version each time we make these sorts of changes.
Some ideas of features we're currently considering:
- Express middleware support using http-context.
- Configurable logging using bole.
- Pluggable message queues to encourage stateless servers.
- Multipart support
- BrowserSync / LiveReload support
Using the API:
npm install yoo
- Flexible: Javascript
- Deployable: Ready to be deployed to Dokku or Heroku
- Composable: Mount Koa servers within or mount within other Koa servers.
- Higher-level: Templating, Routing & Asset Bundling baked-in
API:
Yoo(__dirname)
.auth('username', 'password')
.get('/', 'index.jade')
.exec('make build')
.mount('/api', api)
.compress()
.serve('build')
.cors()
.listen(4000);
Initialize Yoo
at the root
path. Defaults to .
.
Add a route to Yoo
. Routing is powered by kr, so visit there for API details.
Additionally, you may pass a filepath
to handle
, which will render using consolidate.
yoo
.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
.
yoo.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 Yoo
.
Mount inside another app at path
.
app.use(yoo.mount('/dashboard'));
Mount an app inside of Yoo
at path
yoo.mount('/dashboard', app);
Compress CSS and JS assets.
Yoo the entire directory using koa-serve-index
Add a static asset directory
to yoo from
Enable CORS
on the yoo. 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.
npm install
make test
Yoo 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)
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.