Seneca Basic Utility Plugin

1.0.0 · maintenance · verified Sun Apr 19

seneca-basic is a foundational utility plugin for the Seneca.js microservices framework. It provides a small, essential set of action patterns for internal per-process communication, primarily through a 'notes' mechanism, allowing plugins to store and retrieve keyed values or lists. These patterns include `set`, `get`, `push`, `list`, and `pop` for `role:basic, note:true` actions. The package is often bundled by default within the main `seneca` module, simplifying its integration for most users. Its current stable version is 1.0.0, though the latest detailed release notes visible are from v0.5.0 in 2016, indicating a mature and stable, rather than rapidly evolving, project. Release cadence is infrequent, likely tied to Seneca's own maintenance cycles. Its key differentiator is its tightly integrated role within the Seneca ecosystem, providing a lightweight, built-in mechanism for internal plugin coordination without external dependencies.

Common errors

Warnings

Install

Imports

Quickstart

This quickstart initializes Seneca, explicitly loads the seneca-basic plugin, and demonstrates setting, getting, pushing, listing, and popping 'note' values.

const seneca = require('seneca')({
  default_plugins: {
    'basic': false
  }
})

seneca.use(require('seneca-basic'))

async function run() {
  // Set a note
  await seneca.act({ role: 'basic', note: true, cmd: 'set', key: 'myKey', value: 'Hello Seneca!' })
  console.log('Note 'myKey' set.')

  // Get a note
  const resultGet = await seneca.act({ role: 'basic', note: true, cmd: 'get', key: 'myKey' })
  console.log(`Retrieved 'myKey': ${resultGet.value}`)

  // Push to a list
  await seneca.act({ role: 'basic', note: true, cmd: 'push', key: 'myList', value: 10 })
  await seneca.act({ role: 'basic', note: true, cmd: 'push', key: 'myList', value: 20 })
  console.log('Pushed values to 'myList'.')

  // Get the list
  const resultList = await seneca.act({ role: 'basic', note: true, cmd: 'list', key: 'myList' })
  console.log(`Retrieved 'myList': ${resultList.value}`)

  // Pop from the list
  const resultPop = await seneca.act({ role: 'basic', note: true, cmd: 'pop', key: 'myList' })
  console.log(`Popped from 'myList': ${resultPop.value}`)

  const finalResultList = await seneca.act({ role: 'basic', note: true, cmd: 'list', key: 'myList' })
  console.log(`'myList' after pop: ${finalResultList.value}`)

  await seneca.close()
  console.log('Seneca instance closed.')
}

run().catch(console.error)

view raw JSON →