Server

When you invoke the new Grown() constructor an instance of Server is born.

const server = new Grown({
  foo: 'bar',
  baz: {
    buzz: 'bazzinga',
  },
});

Received options are accessible only within the connection:

server.mount((ctx, options) => {
  console.log(options('foo')); // bar
  console.log(options('baz.buzz')); // bazzinga
});

Options can resolve to default values, otherwise they'll throw an error:

// it's fine to have default values
const x = options('some.value', 42);

// but some options should be present!
const y = options('a.required.setting.here');

Module

Props mixin

Methods mixin

Public props static

Public methods static

Private* props static

Private* methods static

Instance methods

  • on(e, cb) — subscribe to events
  • off(e, cb) — unsubscribe from events
  • once(e, cb) — subscribe (once) to events
  • emit(e[, ...]) — broadcast events to listeners
  • run(scope) — dispatch a request through the middleware
  • plug(extensions) — extends the server with additional functionality
  • mount(middleware) — append middleware to the server instance
  • listen([connection]) — starts a new web server connection

➯ Next: Extensions ⟩ Session