@lamware/sqs-json-parser
TypeScript icon, indicating that this package has built-in type declarations

2.0.1 • Public • Published
NPM Discord Apache-2.0

Lamware - SQS JSON Parser

This Lamware Middleware allows you to automatically parse an SQS Queue payload and optionally provide TypeScript typings for the records.

Installation

This package is available via NPM:

yarn add @lamware/sqs-json-parser

# or

npm install @lamware/sqs-json-parser

Usage

import { sqsJsonParser } from '@lamware/sqs-json-parser';
import type { SQSHandler } from 'aws-lambda';
import { lamware } from '@lamware/core';

interface MyRecord {
  title: string;
  content: string;
}

const { handler } = lamware<SQSHandler>()
  .use(sqsJsonParser<MyRecord>({
    // [optional] Whether to throw an error if the JSON fails to parse (default: true)
    throwOnError: false,
  }))
  .execute(async ({ state }) => {
    console.log(state.items); // MyRecord[]
  });

export { handler };

Package Sidebar

Install

npm i @lamware/sqs-json-parser

Weekly Downloads

2

Version

2.0.1

License

GPL-3.0-only

Unpacked Size

39.3 kB

Total Files

7

Last publish

Collaborators

  • oyed