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

bind-rest-aws-lambda

v1.0.1

Published

Module to enable applications build with bind-rest framework to run in AWS Lambda

Downloads

2

Readme

Bind-Rest

Package to enable applications built with bind-rest framework to run as an AWS Lambda function

1.0.1

Installation

This assumes you already have created an application using the bind-rest framework and that it rus as a stand-alone node.js application.

Now in order to run your application on AWS as a Lambda function you need to install this module

npm install bind-rest-aws-lambda

Usage

As you already know, the bind-rest is a Typescript-based framework, so you write your program in Typescript.

Create a file in the root of your application. You can name your file anything you like, for example lambda.ts

Here is an example of lambda.ts This is a typical real-world example.

import {createHandler} from 'bind-rest-aws-lambda'

const handler = createHandler({componentDirs: [__dirname]});

export {handler}

As you can see all you need to provide to createHandler function is the object that implements ApplicationOptions interface from bind-rest framework.

At the minimum you must pass array of directories that contain your components like controllers, middleware, other regular components.

Using the special node.js constance __dirname is a convenient way to say "this directory"

You may pass other options, for example extraComponents. (see below)

The just build your application and use the generated build folder and node_modules directory to create the archive.zip

Upload archive.zip to AWS Lambda (using AWS Console/Lambda)

Provide the name of your controller file and function in the Handler field, Set value to

build/lambda.handler

Configure AWS Api Gateway to use {proxy+} route if using REST API or you can use HTTP API (costs up to 70% less and could be more efficient) If using HTTP API instead of REST API set the $default stage and $default route. If you want to use custom stages instead of default stage then you must also use extra middleware provided by this package to fix the value of 'path'

This is how to add extra middleware to your application:

import {createHandler, FixEvent2Path} from 'bind-rest-aws-lambda'

const handler = createHandler({componentDirs: [__dirname], extraComponents: [FixEvent2Path]});

export {handler}

As you can see you just need to import the FixEvent2Path middleware and provide it as an extraComponent to your application.

This step is not necessary if using REST API or if using HTTP API but with $default stage.