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

amplify-js-local

v0.1.8

Published

Simple Amplify JS wrapper script for use with LocalStack

Downloads

28

Readme

AWS Amplify CLI for LocalStack

This project provides a thin wrapper script amplifylocal for using the Amplify JS library against local APIs provided by LocalStack.

Quick Installation

The amplifylocal command line is published as an npm library:

$ npm install -g amplify-js-local @aws-amplify/cli
...

Note: The dependency @aws-amplify/cli needs to be installed manually (to decouple the two libraries, and allow using arbitrary versions of @aws-amplify/cli under the covers).

The version reported by amplifylocal represents the version of the underlying @aws-amplify/cli installation:

$ amplifylocal --version
4.41.0

Configurations

The following environment variables can be configured:

  • EDGE_PORT: Port under which LocalStack edge service is accessible (default: 4566)
  • LOCALSTACK_HOSTNAME: Target host under which LocalStack edge service is accessible (default: localhost.localstack.cloud)
  • LOCALSTACK_ENDPOINT: Sets a custom endpoint directly. Overrides EDGE_PORT and LOCALSTACK_HOSTNAME (default https://localhost.localstack.cloud:4566)

Deploying a Sample App via the CLI

We can use a sample app provided by AWS to run a quick test for getting started:

$ git clone https://github.com/aws-samples/aws-amplify-graphql
$ cd aws-amplify-graphql
$ npm install
...
$ amplifylocal init
# press [ENTER] a few times to configure the defaults ...
...
$ amplifylocal add auth
...
$ amplifylocal add api
...
$ amplifylocal push
...

Once the deployment is done, you can inspect the created resources via the awslocal command line:

$ awslocal appsync list-graphql-apis
{
    "graphqlApis": [
        {
            "name": "awsamplifygraphql-dev",
            "apiId": "1a6f1f11",
            "authenticationType": "API_KEY",
            "arn": "arn:aws:appsync:us-east-1:000000000000:apis/1a6f1f11",
            "uris": {
                "GRAPHQL": "http://localhost:4566/graphql/1a6f1f11",
                "REALTIME": "ws://localhost:4510/graphql/1a6f1f11"
            }
        },
    ...

Using the Library in your Node.js Program (Backend)

In addition to using the CLI, you should also be able to use the library in your local Node.js program.

// import and apply patches
const amplifyLocal = require('amplify-js-local/lib/index');
amplifyLocal.applyPatches();

// use regular amplify commands below (should automatically use the local endpoints)
...

Using the Library in your ES6 JavaScript Code (e.g., React Frontend)

The library can also be imported and used in your ES6 frontend code (e.g., React.js):

import Amplify from 'aws-amplify';
import applyPatches from 'amplify-js-local/lib/es6';

// apply patches
applyPatches();

// configure Amplify
Amplify.configure(...);

Change Log

  • 0.1.8: Patch AWS_AMPLIFY_ENDPOINT and add HTTPS support
  • 0.1.7: Include esm lib in the dependencies
  • 0.1.2: Patch AWS SDK clients (Cognito IdP/Identity) to use local endpoints
  • 0.1.1: Add patching for @aws-amplify/auth endpoints
  • 0.1.0: Initial release

License

This code is distributed under the Apache License, Version 2.0.