npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@ouroboros/brain

v2.3.1

Published

Package to handle the brain service.

Readme

@ouroboros/brain

npm version Custom License

Shared javascript code for interacting with the brain service created by Ouroboros Coding Inc.

See Releases for changes from release to release.

Installation

Install with npm

foo@bar:~$ npm install @ouroboros/brain

RESTlike Documentation

If you're here to connect to a backend using brain2_oc and you're already familiar with how to connect to body_oc, services in JS/TS projects, then you're probably just looking for the request docs. See the full documentation on the individual RESTlike requests in brain and what they return.

React

If you're connecting to brain via a React framework, you might want to checkout @ouroboros/brain-react which provides several functions and hooks that make using brain in react a snap.

Using brain

Brain uses @ouroboros/body, so some small setup is required there for brain to work as expected.

import body from '@ouroboros/body';
import brain, { errors } from '@ouroboros/brain';

// Set the domain for all requests
body.domain('https://rest.mydomain.com');

// Do we have a session?
const session = localStorage.getItem('session');
if(session) {
  body.session(session);
}

// Sign in
brain.create('signin', {
  email: '[email protected]',
  passwd: '********',
  portal: 'my_app'
}).then(data => {

  // Did we get something back?
  if(data) {
    
    // Store session so we can use it on a reload
    localStorage.setItem('session', data.session);

    // Let body know we have a session
    body.session(data.session);

    // Get user
    brain.read('user').then(storeUser, handleError);
  }
}, error => {
  if(error.code === errors.SIGNIN_FAILED) {
    // notify failed signin
  } else if(error.code === errors.BAD_PORTAL) {
    // notify no access to portal
  } else {
    // notify.... uh oh
  }
})

Errors

Brain provides several error codes unique to the brain2_oc service.

SIGNIN_FAILED, PASSWORD_STRENGTH, BAD_PORTAL, INTERNAL_KEY, BAD_OAUTH, BAD_CONFIG

They can be accessed through errors from @ouroboros/brain.

import { errors } from '@ouroboros/brain';
console.log(errors.SIGNIN_FAILED) // prints 1200

Additionally, if you need to access lower level body_oc errors, you can do so via the body variable.

import { errors } from '@ouroboros/brain';
console.log(errors.body.DATA_FIELDS) // prints 1001

RIGHTS

Brain provides the bits for standard crud operations. These are useful for the permissions and verification calls.

CREATE, READ, UPDATE, DELETE

They can be accessed through RIGHTS from @ouroboros/brain.

import { RIGHTS } from '@ouroboros/brain';
console.log(RIGHTS.CREATE) // prints 1
console.log(RIGHTS.READ | RIGHTS.UPDATE) // prints 6 
console.log(RIGHTS.ALL) // prints 15

RIGHTS_ALL_ID

Useful for creating global permissions, i.e. permissions across a portal or even the whole system, not attached to a specific record ID.

It can be accessed through RIGHTS_ALL_ID from @ouroboros/brain.

import brain, { RIGHTS_ALL_ID, RIGHTS } from '@ouroboros/brain';

brain.update('permissions', {
  user: '18f85e33036d11f08878ea3e7aa7d94a',
  portal: 'my_app',
  rights: {
    my_service_permission: { [RIGHTS_ALL_ID]: RIGHTS.ALL },
    my_other_service_permission: { [RIGHTS_ALL_ID]: RIGHTS.READ },
    my_other_other: { [RIGHTS_ALL_ID]: RIGHTS.CREATE | RIGHTS.DELETE }
  }
}).then(data => {}, error => {});