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

modusign-worker

v0.2.3

Published

sqs consumer for modusign services

Readme

Modusign-worker

Implementing worker app

Installation

Install with npm

npm install modusign-worker

Usage

const { Worker } = require('modusign-worker');

const subscriberName = 'bbcSqsConsumer';
const option = {};

const worker = new Worker({ subscriberName: '', option });

// message parser must be included as middleware
const parseMessage = (message) => {
	const { Subject: subejct, Body: body } = JSON.parse(message);
	return {
		subject,
		body,
	};
}

const middlewareOne = async (context) => {
	// process context #1
	return context;
}

const jobNumberOne = async (context) => {
	// do job #1
}
const jobNumberTwo = async (context) => {
	// do job #2
}

worker.setParser(parseMessage);
worker.use(middlewareOne);

worker.register('job.number.one', jobNumberOne);
worker.register('job.number.two', jobNumberTwo);

Configure worker

  1. choose subscriber and create option object
const { Worker } = require('modusign-worker');

const subscriberName = 'bbcSqsConsumer';
const option = {};

Reference supporting subscribers below which string you can assign subscriberName option must contain properties fit subscriber. Reference subscriber's own document.

  1. create worker instance
const worker = new Worker({ subscriberName: '', option });

Add parser (important)

Add message parser you want to process. The parser get message and must return context which contains subject and so on.

  1. implement parser
const messageParser = (message) => {
	const { Subject: subejct, Body: body, MessageId: messageId, MD5OfBody: md5OfBody } = JSON.parse(message);
	const context = {
		messageId,
		md5OfBody
		subject,
		body,
	};
	return context;
}

subject is required and must be a string. Job handlers find the job it should handle using subject. (like routing path)

  1. set parser on your worker
worker.setParser(messageParser);

Add middlewares

Worker support web-framework style middlewares Add functions that process all context before pass job handlers Middlewares get and return context (if it should be replaced)

  1. implement middlewares
const middleware = (context) => {
	// process context
	return context
}

When middleware returns context, whole context will be replaced.

  1. use middlewares
worker.use(middleware);

Register job handlers

Job handlers can be implemented like controllers Add handlers that contains your business logics. Handlers get whole context, and are excuted following subject

  1. implement handler
const jobHandler = async (context) => {
	// business logic
};
  1. register handler
worker.register('subject', jobHandler);

Set error handler

Define how you handle error

  1. implement handler
const errorHandler = async (error) => {
	// process error
}
  1. set error handler
worker.setErrorHandler(errorHandler);

Supporting Queue Services and subscribers

  1. sqs-consumer Polling amazon sqs.
const worker = new Worker({ subscriberName: 'bbcSqsConsumer', option });

option: sqs-consumer document do not define option.handleMessage.