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 🙏

© 2025 – Pkg Stats / Ryan Hefner

heartisans-core

v1.0.7

Published

Core for heartisans.

Downloads

32

Readme

Heartisans Core

The following services are implemented

  • Config - System configuration that are read in on initialization and consolidated in order of priority
  • Setting - Service setting is a hash list that is store in Redis and can be change during runtime
  • Logger - Logging utility that will log to screen by default and also output records to logger module
  • Message - Messaging module with various communication methods
  • Mongoose - A MongoDb ORM
  • Bookshelf - A MySQL ORM
  • Redis - Redis client manager
const core = require('heartisans-core')

core.<module> // to get the service required

Config

*path can be mulit-level

// Usage

core.config.get('name') // = 'symptom_api'

core.config.getAll()
/*
 = {name: 'symptom_api', ...}
*/

get(path)

Get single config in path such as

getAll()

Get all configs

set(path. value)

Change config during runtime. However, this is not durable and will not survive a process restart.

Setting

*path is a single level and store in a hash on Redis

// Usage

core.setting.get('returnCount') // = 20

core.setting.getAll() /* = {returnCount: 20, ...} */

get(path)

Get single setting in path

getAll()

Get all settings

Logger

const logger = core.logger.create('test:module')

logger.error({err: err}, 'this is a message')
logger.warn({some: data}, 'this is a message')
logger.info('this is a message with no data')
logger.debug({err: err}, 'this is a message')
logger.trace('this is a message with no data')

create(namespace)

Create a logger instance for the module that you are currently working on, a string namespace must be supplied.

Message

Communicate between services / task queue


// Send a message / task to a service / work, no immediate reply
// send (to, subject, message, callback)
core.message.send('medical_history', 'newRecord', {data: 'newData'}, function(err) {
    // err if not successful
})

// Receive a message / task wait for one reply and stop
// receive (subject, callback)
core.message.send('newRecord', function(err, content, message, ack) {
    // err - if not successful
    // content - data replied (JSON)
    // message - the meta data
    // ack - callback to acknowledge that the message is received
})

// Receive a message / task wait for one reply and stop
// listen (subject, handler, callback)
core.message.listen('newRecord', function handler (err, content, message, ack) {
    // err - if not successful
    // content - data replied (JSON)
    // message - the meta data
    // ack - callback to acknowledge that the message is received
    
    ack()
}, function (err) {
    // err - if unable to register a listener
})

// Broadcast a message
// publish (subject, message, callback)
core.message.publish('pushToUser', {id: 10, message: 'Test...'}, function(err) {
    // err if not successful
})

// Subscribe to a broadcast
// subscribe (who, subject, handler, callback)
core.message.subscribe('medical_history', 'newRecord', function handler (err, content, message, ack) {
    // err - if not successful
    // content - data replied (JSON)
    // message - the meta data
    // ack - callback to acknowledge that the message is received
}, function (err) {
    // err - if unable to register a listener
})

// Send a request and expect a immediate response, default timeout 30sec
// request (to, subject, message, callback)
core.message.request('user', 'read', {id: 10}, function(err, user) {
    // err if not successful
})

// Receive a message / task wait for one reply and stop
// response (subject, handler, callback)
core.message.response('newRecord', function handler (err, content, message, res) {
    // err - if not successful
    // content - data replied (JSON)
    // message - the meta data
    // ack - callback to acknowledge that the message is received
    
    // example replies
    res(new Error('Stinks'))
    res(null, 'new name', {yucks: 'great'})
}, function (err) {
    // err - if unable to register a listener
})

send (to, subject, message, callback)

Queue a message / task to be process at a later time

receive (subject, callback)

Receive a single message / task; needs to acknowledge after processing

listen (subject, handler, callback)

Listen for message / task continuously; needs to acknowledge after processing

publish (subject, message, callback)

Publish a message to all subscriber of a subject

subscribe (who, subject, handler, callback)

Subscribe to a subject

request (to, subject, message, callback)

Send a request and expect a immediate response

response (subject, handler, callback)

Response to request

Redis

getClient()

Get a shared redis client

createClient()

Get a new Redis Client

Bookshelf

// just use like bookshelf
const bookshelf = core.bookshelf

mongoose

// just use like mongoose
const mongoose = core.mongoose