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 🙏

© 2024 – Pkg Stats / Ryan Hefner

community-net

v1.0.3

Published

Networking functionality for communities based on the needs and skills of members within the community

Downloads

5

Readme

community-net

Node module that provides networking functionality for communities based on the needs and skills of members within a community

The module assumes you have some kind of database model that stores data about the needs and skills of individual members of your community.

Currently has two emailer components. See Usage section for details

Installation

npm install community-net

Usage

Emailer Config

Each emailer takes a config object with the following interface

{
  transporter: Object, // nodemailer transporter object
  from: String, // Email sender
  subject: String, // Email subject
  onErrorCallback: (err) => { ... }, // Optional
  onSuccessCallback: () => { ... }, // Optional
}

Please see nodemailer documentation for information about email transporters and how to choose an appropriate one for your application.

Cron

The emailer function can be invoked once or on a cron schedule.

Single Invocation

helpWantedEmailer.sendHelpWantedEmail();

or

subNetworkEmailer.sendSubNetEmail();

Scheduled Invocation

The function startCron has two parameters - schedule and timezone. The default values of each is shown below.

var cronJob = emailer.startCron('0 0 0 * * 0', 'America/Los_Angeles')

Please see node-cron documentation for more information.

Help Wanted Emailer

Matches each user with other users whose needs match the user's skill. For example, if you have the following users:

[
  {
    name: 'Bob',
    needs: ['carpentry', 'caulking',]
    skills: ['plumbing', 'electricity']
  },
  {
    name: 'Jack',
    needs: 'plumbing',
    skills: ['farming', 'carpentry']
  },
  {
    name: 'Jill',
    needs: 'carpentry',
    skills: 'robotics'
  }
]
  • Bob will receive an email saying he can help Jack.
  • Jack will receive an email saying he can help Jill.
  • Jill will not receive an email because nobody currently needs robotics help.

Construction

var HelpWanted = require('community-net').HelpWantedEmailer;
var cron = require('cron');

var emailerConfig = {
  ...
};

// See Extension section for more information about connecting to your database
var dbPlugin = {
  ...
};

var emailer = new HelpWanted(cron, emailerConfig, dbPlugin);
var schedule = '0 0 0 * * 0';
var timezone = 'America/Los_Angeles';

emailer.startCron(schedule, timezone);

Sub Network Emailer

Sends an email to each user detailing the status of their sub-network. Sub-networks can be defined in any way based upon how consumers implement the database plugin interface. Sub-networks could be defined by zip code, city, state, neighborhood, interest, sport, etc.

For example, if you have the following users:

[
  {
    name: 'Bob',
    zip: 11111
    needs: ['carpentry', 'caulking',]
    skills: ['plumbing', 'electricity']
  },
  {
    name: 'Jack',
    zip: 11112
    needs: 'plumbing',
    skills: ['farming', 'carpentry']
  },
  {
    name: 'Jill',
    zip: 11111
    needs: 'carpentry',
    skills: 'robotics'
  }
]
  • Bob will receive an email detailing the needs and skills of Jill
  • Jack will receive an email saying nobody is in his sub-network :(
  • Jill will receive an email detailing the needs and skills of Bob

Construction

var SubNetwork = require('community-net').SubNetworkEmailer;
var cron = require('cron');

var emailerConfig = {
  ...
};

// See Extension section for more information about connecting to your database
var dbPlugin = {
  ...
};

var emailer = new SubNetwork(cron, emailerConfig, dbPlugin);
var schedule = '0 0 0 * * 0';
var timezone = 'America/Los_Angeles';

emailer.startCron(schedule, timezone);

Extension

Community Net can be extended to accomodate whatever database solution your app uses.

The following database plugins have already been implemented:

To create a new plugin, create an object that implements the following interface and inject it into an emailer at construction.

{
  function getUsers(onSuccessCallback, onErrorCallback) {
    // returns all users in the database
  }

  // user param is a member of the array returned from the getUsers function on this interface
  function getSubNetworkForUser(user, onSuccessCallback, onErrorCallback) {
    // returns all users in a particular user's sub network
  }

  // user param is a member of the array returned from the getUsers function on this interface
  function getUsersToHelp(user, onSuccessCallback, onErrorCallback) {
    // returns all users that a particular user can help
  }
}

All database user documents should be converted to the Community Net user obejct before being consumed by the module. The user object used by Community Net is defined below

{
  name: String,
  email: String,
  needs: [String, ..., String],
  skills: [String, ..., String]
}