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

rescript-aws-sdk-v3

v2.0.0

Published

ReScript bindings against the AWS JavaScript SDK v3

Downloads

3

Readme

ReScript AWS SDK v3 bindings

A set of bindings for the AWS JavaScript SDK v3 for use with ReScript.

These are an unofficial set of ReScript bindings - they are not officially provided by or endorsed by AWS.

The bindings are still a bit experimental as they haven't been validated extensively and some SDKs are missing due to generation issues that need to be resolved (see the TODO for more details).

Installation

npm i rescript-aws-sdk-v3

and add to your bsconfig.json dependencies list:

  ...
  "bs-dependencies": ["rescript-aws-sdk-v3"]

Usage

  1. For each AWS SDK you wish to use, install the corresponding client packages e.g. for S3:
npm i @aws-sdk/client-s3
  1. Create a client for the corresponding API:
open AwsSdkV3;
let client = S3.createClient();
  1. Identify the API you wish to call (e.g. GetObject). You can then construct the command by passing the request type to make() (in some instances make() won't be present - use new() instead)
// make() is used to construct the equivalent of GetObjectCommand - note that () is always needed to indicate the end of parameters
let command = S3.GetObject.make(~bucket="my-bucket", ~key="path/to/key.json", ());

(in the cases that make() has no arguments, e.g. S3.ListBuckets, use let command = S3.ListBuckets.make();)

  1. Dispatch the command with send():
S3.GetObject.send(client, command)
  ->Promise.then(result => {
      Js.log2("Object body: ", )
      Promise.resolve()
  })

Error Handling

The AWS SDK throws ordinary JavaScript exceptions. The rescript-promise library wraps these as ReScript errors, so to filter them in your catch handler, you will need code like the following:

  ->
  ->catch(error => {
    switch error {
    | JsError(error) =>
      switch AwsSdkV3.Exn.asAwsError(error) {
      | Some(awsError) =>
        // The `name` property is set to the AWS API error code (e.g. AccessDenied, NoSuchKey, etc.)
        switch awsError.name {
        | "NoSuchBucket" => Js.log("The specified bucket does not exist")
        | _ => Js.log2("An AWS Error occurred", awsError.name)
        }
      | None => Js.log2("An unknown JS error occurred", error)
      }
      | _ => Js.log2("An unknown ReScript error occurred", error)
    }
    Promise.resolve()
  })

Copyright (C) 2021 Chris Armstrong - see LICENSE for more details on licensing