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

thegeek

v0.0.2

Published

TheGeek - Send/Receive IMAP Email, create jobs for the emails to run through and also send SMS, with only a few lines of code!

Downloads

5

Readme

TheGeek

I made TheGeek to essentially bootstrap my projects involving email and sms (and eventually have also manage tasks). I am sort of new to making Node Modules so I sure this can be improved. Currently TheGeek can send and reveive emails and run jobs against said emails. It also can send SMS (using Twilio).

Version

0.0.1

Tech

Currently TheGeek relies on the following modules;

  • emailjs : Sending Email
  • lodash : I only use this in one spot for doing a deep clone, it probably could be phased out.
  • mail-listener2 : Listening for and parsing new mail.
  • twilio : send SMS.

Installation

npm install thegeek

Usage

Simple script that will watch your email and send a text to the given number with the email subject as the SMS body, then it will reply to the email with the status of the text using HTML. It will also queue a test job and run the email against it.

var Geek = require('thegeek'),
	geek = new Geek();

//Configure IMAP
//This connection is super simple, it assumes incoming and outgoing use same credentials and uses the default ports of 143 in / 587 out.
geek.imap.connect({
	host : "mail.somedomain.com",
	username : "[email protected]",
	password : "saltytearsofjoy"
}, function() {
	console.log("Imap Configured!");
});

//Configure Twilio
geek.sms.connect({
	sid : "ABC1234567890987654321123456789009",//Twilio SID
	token : "a1a1a1a1b2b2b2b2c3c3c3c3d4d4d4d4",//Twilio Token
	number : "+15555551234" //Twilio Number
}, function() {
	console.log("SMS Configured!");
});

//Our Job
var testJob = function(mail) {
	 if(mail.subject === "HELP!"){
	 	console.log("Add something useful in this function, because someone needs HELP!");
	 } 	
};

//Give the geek a job to do.
geek.imap.addJob("MyTestJob", testJob);


//On mail event.
geek.imap.on("mail", function(mail, index, attributes) {
	//run jobs (in this case there is only one)
	geek.imap.runJobs(mail);
	
	//Twilio message, send to that phone number with the email subject as the message
	var message = {
		to : "+15551239898",
		body : mail.subject
	};
	
	//send message
	geek.sms.send(message, function(err, message) {
		//set up reply email. 
		var reply = {
			text : "Testing",
			from : "<[email protected]>",
			to : mail.from[0].address,
			cc : "",
			subject : "Re: " + mail.subject,
			attachment : [{
			data : "",
			alternative : true
			}]
		};
		
		if (err) {
			reply.attachment[0].data = "<html><b><u>ERROR:</u></b><br>" + err.message + "</html>";
		} else {
			reply.attachment[0].data = "<html><b><u>SUCCESS:</u></b><br>" + message + "</html>";
		}	
		
		//send reply email.
		geek.imap.send(reply);
	});
});

geek.imap.start(function() {
	console.log("Geek has started!");
});

This is still a work in progress. I hope to add the ability to unzip files, add some transformation functions, maybe add some other listeners for services such as Twitter or Facebook, also I want to add the ability for this to add multiple email listeners (You can technically define multiple geeks to achieve the same thing, but I want the single instance to be able to do it).


I will document more later as this is just 0.0.1, check out the index.js though for now to see all the other config options for IMAP.

MIT

Free to use for whatever