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

falcor-lambda

v0.1.2

Published

creates AWS Lambda handler from Falcor's data source

Downloads

13

Readme

falcor-lambda Build Status npm version

It creates AWS Lambda handler from Falcor's data source.

You can setup a Falcor endpoint on AWS API Gateway and Lambda using serverless-falcor-starter. This project exposes the Falcor endponit using falcor-lambda.

Usage

You can create a Lambda handler function. For example:

/* handler.js */

import dataSourceHanlder from "falcor-lambda";
import Router from "falcor-router";

module.exports.handler = dataSourceHanlder(() => new Router([{
  route: "greeting",
  get: function() {
    return { path: ["greeting"], value: "Hello, world" };
  }
}]));

API

function dataSourceHanlder(sourceCreateFn: SourceCreateFn, option?: Option): LambdaHandlerFunction

Creates a Lambda handler.

  • sourceCreateFn: A function which returns a Falcor DataSource.

type SourceCreateFn: (event?: any, context?: any) => DataSource

  • event: An event argument of the AWS Lambda function.
  • context: A context argument of the AWS Lambda function.

type Option: {debug?: boolean, eventToFalcorContext?: (event: any, context: any) => FalcorContext}

  • debug: Allows to output debug log.
  • eventToFalcorContext: This function creates a FalcorContext object from the Lambda's event or context value. See also Request and event mapping

type FalcorContext: {method: string, jsonGraph?: JSONGraphEnvelope, callPath?: Path, arguments?: any[], pathSuffixes?: Pathset[], paths?: PathSet[]}

FalcorContext represents Falcor DataSource's get/set/call arguments.

Request and event mapping

If you integrate a Lambda handler with AWS API Gateway, you must create a mapping from request to Lambda events with API Request Mapping. falcor-lambda assumes that the request parameter of the GET/POST method will be mapped in the following way:

  • GET
"requestTemplates": {
  "application/json": {
    "method": "$input.params().querystring.method",
    "paths": "$util.escapeJavaScript($input.params().querystring.paths)"
  }
}
  • POST
"requestTemplates": {
  "application/json": {
    "method": "$input.json('$.method')",
    "jsonGraph": "$input.json('$.jsonGraph')",
    "callPath": "$input.json('$.callPath')",
    "arguments": "$input.json('$.arguments')",
    "pathSuffixes": "$input.json('$.pathSuffixes')",
    "paths": "$input.json('$.paths')"
  }
}

If you want the complete example, please see falcor-lambda-example/falcor/model/s-function.json

By the default, falcor-lambda parses the each value of the event object using JSON.parse because assumption that they are stringified JSON parameter. If you use other mapping, witch is different from the above sample, you can pass through request values to your DataSource with customizing eventToFalcorContext.

License

This software is released under the MIT License, see LICENSE.txt.