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
  • clients() — Returns a list of active users connected through WebSockets