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

aws-lambda-typescript

v5.1.1

Published

simple build pipeline for creating lambda functions in typescript

Downloads

108

Readme

aws-lambda-typescript

build pipeline for easily building aws lambda functions with typescript.

creating your function

  • create a new node project and npm init it.
  • npm install --save-dev gulp aws-lambda-typescript
  • create a gulpfile.js file
  • add the following to your gulpfile.js:
const gulp = require('gulp');
const awsLambdaTypescript = require('aws-lambda-typescript');

awsLambdaTypescript.registerBuildGulpTasks(gulp, __dirname);
  • run gulp lambda:init to set everything up

The following files will be created in the root of your project:

  • index.ts - the entry point of your typescript lambda function
  • .eslintrc.js - configures the linter
  • tsconfig.json - configures the typescript compiler
  • debug.js - debugging entrypoint allows simple debugging of your function in a local express instance
  • lambda-config.js - contains the deployment details for your function

The following commands are then available:

  • gulp lambda:init - sets up the above files
  • gulp lambda:run - runs your function in a local express instance, defaults to port 9000
  • gulp lambda:package - packages your function up ready for deployment by bundling everything together with webpack
  • gulp lambda:deploy - packages and deploys your function
  • gulp lambda:info - get info about the current state of your lambda function

running locally

after running gulp lambda:run you can test your function locally by posting to localhost:9000/

debugging

By setting your debuggers entry point to the debug.js file in the root of your project you can easily step through your function.

debugging in vscode

Go to the debug tab in visual studio at the top where it says "debug" and probably "no configurations" there should be a gear icon. Click it and you should be taken to your launch.json file that will look something like:

{
  "version": "0.2.0",
  "configurations": [
    {
      "type": "node",
      "request": "launch",
      "name": "Launch Program",
      "program": "${workspaceRoot}\\index.js",
      "outFiles": [
          "${workspaceRoot}/out/**/*.js"
      ]
    }
  ]
}

Then you should be able to debug as normal.

options

By altering lambda-config.js in the root of your project you can set the following options:

module.exports = {
  localPort: 9000, // set the port to run the local server on
  region: 'us-west-2' // set the aws region
};

There are lots of other options available but it's probably best to look at the lambda-config.js file in https://github.com/ThoughtWorksStudios/node-aws-lambda as we use that.

how it works

When running locally we spin up an express instance then use "ts-node" to allow the transparent usage of typescript and allow debugging to work. This is great but has some overhead, to keep spin-up times to a miminum we do something different when we package everything up for release. When we package the function up we run it through webpack and do a one-time transform to javascript, in this way we pay no runtime penalty for typescript compilation.

todo

  • A simple way to run tests
  • check interaction with other aws resources when running locally