Skip to content

A wrapper over the aws-sdk for NodeJS making it more standardised.

Notifications You must be signed in to change notification settings

hexlabsio/aws-sdk

Repository files navigation

@hexlabs/aws-sdk

A more standardised aws-sdk written in TypeScript. Generated from the original sdk, this library wraps aws-sdk transforming each request so that pagination is standardised.

All Responses have the same format, The array of results is extracted for you and placed into member:

type Response<T> = { member: T[]; totalItems: T['length']; next?: string };

Install

npm install -S @hexlabs/aws-sdk

Before

import { Lambda } from 'aws-sdk';
const {Functions, NextMarker} = await new Lambda({ region: 'eu-west-1' })
  .listFunctions({MaxItems: 1, Marker: '<nextToken goes here>'}).promise();

After

import { Lambda } from '@hexlabs/aws-sdk';
const {member, totalItems, next} = await Lambda.client({ region: 'eu-west-1' })
  .listFunctions({limit: 1, next: '<nextToken goes here>'});

The Problem

Each service call in aws-sdk responds with an object that is unique to that call.

For example: this is what Lambda.listFunctions returns in the original sdk

{
  NextMarker?: string;
  Functions?: FunctionList;
}

Here is what DynamoDB.listTables returns in the original sdk

{
  TableNames?: TableNameList;
  LastEvaluatedTableName?: TableName;
}

This library transforms these to the following:

//Dynamo.listTables return type
{
  member: TableNameList,
  next?: string
}
//Lambda.listFunctions return type
{
  member: FunctionList,
  next?: string
}

Any call that can be limited or paged will contain the keys limit and next for the user to supply those tokens instead of Marker or MaxItems or NextToken or whatever.

A subtle difference, but better, enjoy :)

About

A wrapper over the aws-sdk for NodeJS making it more standardised.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published