yoo

1.8.7 • Public • Published

Yoo

kangaroo

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.

Goal

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

Installation

Using the API:

npm install yoo

Features

  • 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

Example

API:

Yoo(__dirname)
  .auth('username', 'password')
  .get('/', 'index.jade')
  .exec('make build')
  .mount('/api', api)
  .compress()
  .serve('build')
  .cors()
  .listen(4000);

API

Yoo(root)

Initialize Yoo at the root path. Defaults to ..

Yoo.{get,post,put,delete,...}(route[, middleware, ...], handle)

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)
Yoo.favicon(path)

Set a favicon at path

Yoo.auth(user, pass)

Add basic auth with a user and pass.

Yoo.logger([fn])

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".

Yoo.exec(command)

Execute a command every refresh

Yoo.use(generator)

Pass additional middleware generator's to Yoo.

Yoo.mount(path)

Mount inside another app at path.

app.use(yoo.mount('/dashboard'));
Yoo.mount(path, app)

Mount an app inside of Yoo at path

yoo.mount('/dashboard', app);
Yoo.compress()

Compress CSS and JS assets.

Yoo.directory()

Yoo the entire directory using koa-serve-index

Yoo.static(directory)

Add a static asset directory to yoo from

Yoo.cors([options])

Enable CORS on the yoo. options get passed directly to node-cors.

Yoo.listen(port, fn)

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.

Test

npm install
make test

Why Yoo?

Yoo is short for Kangaroo. I wrote this while visiting Australia for CampJS and I have Kangaroos on my mind.

Credits

Kangaroo Icon by Olivier Guin

License

(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.

Readme

Keywords

Package Sidebar

Install

npm i yoo

Weekly Downloads

11

Version

1.8.7

License

none

Unpacked Size

25.2 kB

Total Files

6

Last publish

Collaborators

  • bdentino
  • abpai