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

@educational-technology-collective/etc_http_aws_api_gateway_wrapper

v3.0.0

Published

## Description This package offers a Wrapper that can be used to log messages to specially configured AWS Gateway APIs. Instantiation of a Wrapper involves providing 3 required arguments: the URL for the AWS API Gateway, the name of the S3 Bucket, and th

Downloads

12

Readme

ETC HTTP AWS API Gateway Wrapper

Description

This package offers a Wrapper that can be used to log messages to specially configured AWS Gateway APIs. Instantiation of a Wrapper involves providing 3 required arguments: the URL for the AWS API Gateway, the name of the S3 Bucket, and the path that messages should be saved to in the S3 bucket.

The Wrapper logs errors to console.error by default.

The Wrapper has two methods: AWSAPIGatewayWrapper#request and AWSAPIGatewayWrapper#requestAsync.

AWSAPIGatewayWrapper#request will handle errors by logging the error to the errorHandler specified in the constructor. In the event of an error, it will then continue to retry the request after the number of seconds specified by the constructor's retry argument. This method wraps the requestAsync method so that the user doesn't need to handle asynchronous errors.

AWSAPIGatewayWrapper#requestAsync will return a Promise that will resolve with a Response object or reject with an error. It will log errors to the errorHandler specified in the constructor. This method does not automatically retry the request if an error happens. It gives you more control over error handling.

Each logged S3 object is named by the AWS Gateway server using a combination of timestamp and UUID. E.g., 1625155259384-9a47660f-3ffe-469d-b1d5-2de875a6a022. In that example, 1625155259384 is the timestamp and 9a47660f-3ffe-469d-b1d5-2de875a6a022 is the UUID.

Installation Instructions

First change directory into the base directory of your repository.

Install the dependency and add it to your package.json file.

npm add @educational-technology-collective/etc_http_aws_api_gateway_wrapper

Usage

Import the Wrapper.

import { AWSAPIGatewayWrapper } from "@educational-technology-collective/etc_http_aws_api_gateway_wrapper"

Instantiating AWSAPIGatewayWrapper

constructor

  • options <Object>
    • url <string> The URL for the AWS API.
    • bucket <string> The name of the AWS S3 Bucket.
    • path <string> The path of the object that will be saved into the S3 bucket.
    • retry <number> An optional number of seconds to wait before retrying after an error. This argument is relevant only when using the AWSAPIGatewayWrapper#request method. It is ignored by AWSAPIGatewayWrapper#requestAsync. Set this to null for no retry. Default: 1000
    • errorHandler <Function> An optional error handler. Set this to null in order to disable it. Default: console.error.

AWSAPIGatewayWrapper#requestAsync(data)

  • data <any> The object or primitive that will be JSON serialized and logged to the S3 Bucket.
  • Returns: <Promise<Response>>

AWSAPIGatewayWrapper#request(data)

  • data <any> The object or primitive that will be JSON serialized and logged to the S3 Bucket.
  • Returns: <void>

Example:

let awsAPIGatewayWrapper: AWSAPIGatewayWrapper = new AWSAPIGatewayWrapper(
    {
        url: "https://example.com",
        bucket: "the-name-of-the-bucket",
        path: "the-path", // e.g., path/to/resource
        retry: 1000, // optional
        errorHandler: console.error // optional
    });

Complete Example

This is an example of using the request method in order to send data to an S3 bucket.


import { AWSAPIGatewayWrapper } from "@educational-technology-collective/etc_http_aws_api_gateway_wrapper";

let timestamp: number = Date.now();

let awsAPIGatewayWrapper: AWSAPIGatewayWrapper = new AWSAPIGatewayWrapper(
    {
        url: "https://example.com",
        bucket: "the-name-of-the-bucket",
        path: "the-path", // e.g., path/to/resource
        retry: 1000, // optional
        errorHandler: console.error // optional
    });

awsAPIGatewayWrapper.request(["This request was made by AWSAPIGatewayWrapper#request.", timestamp]);

This is an example of making an asynchronous HTTP request to an S3 bucket.


import { AWSAPIGatewayWrapper } from "@educational-technology-collective/etc_http_aws_api_gateway_wrapper";

let awsAPIGatewayWrapper: AWSAPIGatewayWrapper = new AWSAPIGatewayWrapper(
    {
        url: "https://example.com",
        bucket: "the-name-of-the-bucket",
        path: "the-path", // e.g., path/to/resource
        errorHandler: console.error // optional
    });

(async function () {

    try {

        let timestamp: number = Date.now();

        let response: Response = await awsAPIGatewayWrapper.requestAsync(["This request was made by AWSAPIGatewayWrapper#requestAsync.", timestamp]);
    }
    catch (e) {
        console.error(e);
    }
})();