2.0.0 • Published 10 months ago

@janiscommerce/aws-listeners v2.0.0

Weekly downloads
1
License
ISC
Repository
github
Last release
10 months ago

aws-listeners

Build Status Coverage Status npm version

A Package to implement lambda listeners for some AWS Service events

Installation

npm install @janiscommerce/aws-listeners

Usage

const { SQSListener, ServerlessHandler } = require('@janiscommerce/aws-listeners');

class SomeSQSFunction extends SQSListener {

	async process() {
		// process the message
	}
}

module.exports.handler = (...args) => ServerlessHandler.handle(SomeSQSFunction, ...args);

Supported AWS Services

  • SQS Amazon Simple Queue Service (SQS) is a fully managed message queuing service that enables you to decouple and scale microservices, distributed systems, and serverless applications.
  • S3 Amazon Simple Storage Service (Amazon S3) is an object storage service that offers industry-leading scalability, data availability, security, and performance.
  • SNS Amazon Simple Notification Service (SNS) is a highly available, durable, secure, fully managed pub/sub messaging service that enables you to decouple microservices, distributed systems, and serverless applications.

Common method

There is one common method that must be implemented in all the listeners:

async process()

This method is required, and should have the logic of your Listener.

Extended documentation

For a more detailed explanation you can go to the following documents

Examples

S3 Listener

'use strict';

const { S3Listener, S3ServerlessHandler } = require('@janiscommerce/aws-listeners');

class MyS3EventListener extends S3Listener {

	async process() {
		const data = await this.getData();
		/* ... Your code to process the s3 event goes here ... */
	}

}

module.exports.handler = (...args) => S3ServerlessHandler.handle(MyS3EventListener, ...args);