Coder Social home page Coder Social logo

postlight / serverless-typescript-starter Goto Github PK

View Code? Open in Web Editor NEW
710.0 47.0 62.0 5.28 MB

πŸ—„πŸ™…β€β™€οΈ Deploy your next serverless JavaScript function in seconds

Home Page: https://postlight.com/labs/modern-serverless-starter-kit

JavaScript 24.18% TypeScript 75.82%
serverless babel webpack jest eslint prettier aws starter-kit lambda-functions labs

serverless-typescript-starter's Introduction

logo Greenkeeper badge CircleCI

Postlight's Modern Serverless Starter Kit adds a light layer on top of the Serverless framework, giving you the latest in modern JavaScript (ES6 via Webpack, TypeScript if you want it, testing with Jest, linting with ESLint, and formatting with Prettier), the ease and power of Serverless, and a few handy helpers (like functions for handling warm functions and response helpers).

Once installed, you can create and deploy functions with the latest ES6 features in minutes, with linting and formatting baked in.

Read more about it in this handy introduction.

Note: Currently, this starter kit specifically targets AWS.

Install

# If you don't already have the serverless cli installed, do that
yarn global add serverless

# Use the serverless cli to install this repo
serverless install --url https://github.com/postlight/serverless-typescript-starter --name <your-service-name>

# cd into project and set it up
cd <your-service-name>

# Install dependencies
yarn install

Development

Creating and deploying a new function takes two steps, which you can see in action with this repo's default Hello World function (if you're already familiar with Serverless, you're probably familiar with these steps).

1. Add your function to serverless.yml

In the functions section of ./serverless.yml, you have to add your new function like so:

functions:
  hello:
    handler: src/hello.default
    events:
      - http:
          path: hello
          method: get

Ignoring the scheduling event, you can see here that we're setting up a function named hello with a handler at src/hello.ts (the .default piece is just indicating that the function to run will be the default export from that file). The http event says that this function will run when an http event is triggered (on AWS, this happens via API Gateway).

2. Create your function

This starter kit's Hello World function (which you will of course get rid of) can be found at ./src/hello.ts. There you can see a basic function that's intended to work in conjunction with API Gateway (i.e., it is web-accessible). Like most Serverless functions, the hello function is asynchronous and accepts an event & context. (This is all basic Serverless; if you've never used it, be sure to read through their docs.


You can develop and test your lambda functions locally in a few different ways.

Live-reloading functions

To run the hello function with the event data defined in fixtures/event.json (with live reloading), run:

yarn watch:hello

API Gateway-like local dev server

To spin up a local dev server that will more closely match the API Gateway endpoint/experience:

yarn serve

Test your functions with Jest

Jest is installed as the testrunner. To create a test, co-locate your test with the file it's testing as <filename>.test.ts and then run/watch tests with:

yarn test

Adding new functions/files to Webpack

When you add a new function to your serverless config, you don't need to also add it as a new entry for Webpack. The serverless-webpack plugin allows us to follow a simple convention in our serverless.yml file which is uses to automatically resolve your function handlers to the appropriate file:

functions:
  hello:
    handler: src/hello.default

As you can see, the path to the file with the function has to explicitly say where the handler file is. (If your function weren't the default export of that file, you'd do something like: src/hello.namedExport instead.)

Keep your lambda functions warm

Lambda functions will go "cold" if they haven't been invoked for a certain period of time (estimates vary, and AWS doesn't offer a clear answer). From the Serverless blog:

Cold start happens when you execute an inactive (cold) function for the first time. It occurs while your cloud provider provisions your selected runtime container and then runs your function. This process, referred to as cold start, will increase your execution time considerably.

A frequently running function won't have this problem, but you can keep your function running hot by scheduling a regular ping to your lambda function. Here's what that looks like in your serverless.yml:

custom:
  warmup:
    enabled: true
    events:
      - schedule: rate(5 minutes)
    prewarm: true
    concurrency: 2

The above config would keep all of your deployed lambda functions running warm. The prewarm flag will ensure your function is warmed immediately after deploys (so you don't have to wait five minutes for the first scheduled event). And by setting the concurrency to 2, we're keeping two instances warm for each deployed function.

Under custom.warmup, you can set project-wide warmup behaviors. On the other hand, if you want to set function-specific behaviours, you should use the warmup key under the select functions. You can browse all the options here.

Your handler function can then handle this event like so:

const myFunc = (event, context, callback) => {
  // Detect the keep-alive ping from CloudWatch and exit early. This keeps our
  // lambda function running hot.
  if (event.source === 'serverless-plugin-warmup') {
    // serverless-plugin-warmup is the source for Scheduled events
    return callback(null, 'pinged');
  }

  // ... the rest of your function
};

export default myFunc;

Copying and pasting the above can be tedious, so we've added a higher order function to wrap your run-warm functions. You still need to config the ping in your serverless.yml file; then your function should look like this:

import runWarm from './utils';

const myFunc = (event, context, callback) => {
  // Your function logic
};

export default runWarm(myFunc);

Pruning old versions of deployed functions

The Serverless framework doesn't purge previous versions of functions from AWS, so the number of previous versions can grow out of hand and eventually filling up your code storage. This starter kit includes serverless-prune-plugin which automatically prunes old versions from AWS. The config for this plugin can be found in serverless.yml file. The defaults are:

custom:
  prune:
    automatic: true
    number: 5 # Number of versions to keep

The above config removes all but the last five stale versions automatically after each deployment.

Go here for more on why pruning is useful.

Environment Variables

If you have environment variables stored in a .env file, you can reference them inside your serverless.yml and inside your functions. Considering you have a NAME variable:

In a function:

process.env.NAME

In serverless.yml:

provider:
  name: ${env:NAME}
  runtime: nodejs12.x

You can check the documentation here.

Deploy

Assuming you've already set up your default AWS credentials (or have set a different AWS profile via the profile field):

yarn deploy

yarn deploy will deploy to "dev" environment. You can deploy to stage or production with:

yarn deploy:stage

# -- or --

yarn deploy:production

After you've deployed, the output of the deploy script will give you the API endpoint for your deployed function(s), so you should be able to test the deployed API via that URL.


πŸ”¬ A Labs project from your friends at Postlight. Happy coding!

serverless-typescript-starter's People

Contributors

abumalick avatar adampash avatar bardawilpeter avatar dependabot[bot] avatar gareys avatar ginatrapani avatar greenkeeper[bot] avatar jadtermsani avatar kevboh avatar wajeehzantout avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

serverless-typescript-starter's Issues

An in-range update of @typescript-eslint/parser is breaking the build 🚨

The devDependency @typescript-eslint/parser was updated from 2.19.0 to 2.19.1.

🚨 View failing branch.

This version is covered by your current version range and after updating it in your project the build failed.

@typescript-eslint/parser is a devDependency of this project. It might not break your production code or affect downstream projects, but probably breaks your build or test tools, which may prevent deploying or publishing.

Status Details
  • ❌ ci/circleci: test: Your tests failed on CircleCI (Details).
  • ❌ ci/circleci: build: Your tests failed on CircleCI (Details).

Release Notes for v2.19.1

2.19.1 (2020-02-10)

Bug Fixes

  • eslint-plugin: [unbound-method] blacklist a few unbound natives (#1562) (4670aab)
  • typescript-estree: ts returning wrong file with project references (#1575) (4c12dac)
Commits

The new version differs by 5 commits.

  • 1c8f0df chore: publish v2.19.1
  • 4c12dac fix(typescript-estree): ts returning wrong file with project references (#1575)
  • e9cf734 docs(eslint-plugin): fix typo in readme
  • 10d86b1 docs(eslint-plugin): [no-dupe-class-members] fix typo (#1566)
  • 4670aab fix(eslint-plugin): [unbound-method] blacklist a few unbound natives (#1562)

See the full diff

FAQ and help

There is a collection of frequently asked questions. If those don’t help, you can always ask the humans behind Greenkeeper.


Your Greenkeeper Bot 🌴

An in-range update of eslint-plugin-import is breaking the build 🚨

The devDependency eslint-plugin-import was updated from 2.18.2 to 2.19.0.

🚨 View failing branch.

This version is covered by your current version range and after updating it in your project the build failed.

eslint-plugin-import is a devDependency of this project. It might not break your production code or affect downstream projects, but probably breaks your build or test tools, which may prevent deploying or publishing.

Status Details
  • βœ… ci/circleci: build: Your tests passed on CircleCI! (Details).
  • ❌ ci/circleci: test: Your tests failed on CircleCI (Details).

Commits

The new version differs by 46 commits.

  • 9b76635 Bump to v2.19.0
  • 47a232e [resolvers/webpack] v0.12.0
  • 26ad476 [resolvers/webpack] [deps] update debug, enhanced-resolve, has, interpret, lodash, resolve, semver
  • 3f0e8f3 [resolvers/node] [Deps] update resolve
  • 7190c3e bump utils to v2.5.0
  • a60e5c6 [New] no-commonjs: add allowConditionalRequire option
  • 414c923 [New] enable passing cwd as an option to eslint-import-resolver-webpack
  • 8224e51 [New] order/no-extraneous-dependencies: Alphabetize imports within groups
  • f12ae59 [New] no-duplicates: add a considerQueryString option to handle false positives when using some webpack loaders.
  • 2d3d045 [fix] importType: Accept '@example' as internal
  • 0426f16 [New] order: add pathGroups option to add support to order by paths
  • 99b3fbf [Fix] no-extraneous-dependencies: Add support for export from
  • 21bf8c6 [Fix] no-cycle: should not warn for Flow imports
  • 0cd5e43 [Fix] no-unused-modules: fix crash due to export *
  • 05085bb [flow] no-unused-modules: add flow type support

There are 46 commits in total.

See the full diff

FAQ and help

There is a collection of frequently asked questions. If those don’t help, you can always ask the humans behind Greenkeeper.


Your Greenkeeper Bot 🌴

An in-range update of aws-sdk is breaking the build 🚨

The devDependency aws-sdk was updated from 2.614.0 to 2.615.0.

🚨 View failing branch.

This version is covered by your current version range and after updating it in your project the build failed.

aws-sdk is a devDependency of this project. It might not break your production code or affect downstream projects, but probably breaks your build or test tools, which may prevent deploying or publishing.

Status Details
  • ❌ ci/circleci: build: Your tests failed on CircleCI (Details).
  • ❌ ci/circleci: test: Your tests failed on CircleCI (Details).

Release Notes for Release v2.615.0

See changelog for more information.

Commits

The new version differs by 1 commits.

See the full diff

FAQ and help

There is a collection of frequently asked questions. If those don’t help, you can always ask the humans behind Greenkeeper.


Your Greenkeeper Bot 🌴

An in-range update of @typescript-eslint/parser is breaking the build 🚨

The devDependency @typescript-eslint/parser was updated from 1.9.0 to 1.10.0.

🚨 View failing branch.

This version is covered by your current version range and after updating it in your project the build failed.

@typescript-eslint/parser is a devDependency of this project. It might not break your production code or affect downstream projects, but probably breaks your build or test tools, which may prevent deploying or publishing.

Status Details
  • ❌ ci/circleci: test: Your tests failed on CircleCI (Details).
  • ❌ ci/circleci: build: Your tests failed on CircleCI (Details).

FAQ and help

There is a collection of frequently asked questions. If those don’t help, you can always ask the humans behind Greenkeeper.


Your Greenkeeper Bot 🌴

Feature Suggestion - Sane Defaults for Jest Testing

Bootstrapping the project from scratch doesn't define any configuration for Jest out of the box. I'm pretty sure we could come up with some sane defaults for basic JS testing and let people expand from there. Perhaps even providing various examples in the readme/wiki.

An in-range update of serverless is breaking the build 🚨

Version 1.31.0 of serverless was just published.

Branch Build failing 🚨
Dependency serverless
Current Version 1.30.3
Type devDependency

This version is covered by your current version range and after updating it in your project the build failed.

serverless is a devDependency of this project. It might not break your production code or affect downstream projects, but probably breaks your build or test tools, which may prevent deploying or publishing.

Status Details
  • ❌ ci/circleci: test: Your tests failed on CircleCI (Details).
  • βœ… ci/circleci: build: Your tests passed on CircleCI! (Details).

Release Notes 1.31.0 (11.09.2018)
Commits

The new version differs by 42 commits.

  • 47901ae Merge pull request #5287 from serverless/release-v-1-31-0
  • a0ba3df Releasing v1.31.0
  • f53f047 Merge pull request #5258 from pinkerton/master
  • 7616fb2 Fix serverless-cloudflare-workers version
  • e2050f9 Fix serverless-cloudflare-workers version in enterprise
  • 8c5511c Update PoP number
  • 1e37c2c Add docs link to menu
  • 4bbdacd Change path from cloudflare-workers to cloudflare
  • 30db8e9 Add to providers page
  • 0abdf19 Add image headers to docs
  • c94db19 Add links to Workers page
  • 0ec216a Add note about updated route handling
  • c4f358c Update version in docs
  • 9f1c334 Merge pull request #5276 from andriyor/master
  • 87a09d3 Update instructions a bit

There are 42 commits in total.

See the full diff

FAQ and help

There is a collection of frequently asked questions. If those don’t help, you can always ask the humans behind Greenkeeper.


Your Greenkeeper Bot 🌴

An in-range update of webpack is breaking the build 🚨

The devDependency webpack was updated from 4.35.3 to 4.36.0.

🚨 View failing branch.

This version is covered by your current version range and after updating it in your project the build failed.

webpack is a devDependency of this project. It might not break your production code or affect downstream projects, but probably breaks your build or test tools, which may prevent deploying or publishing.

Status Details
  • ❌ ci/circleci: test: Your tests failed on CircleCI (Details).
  • ❌ ci/circleci: build: Your tests failed on CircleCI (Details).

Release Notes for v4.36.0

Features

  • SourceMapDevToolPlugin append option now supports the default placeholders in addition to [url]
  • Arrays in resolve and parser options (Rule and Loader API) support backreferences with "..." when overriding options.
Commits

The new version differs by 42 commits.

  • 95d21bb 4.36.0
  • aa1216c Merge pull request #9422 from webpack/feature/dot-dot-dot-merge
  • b3ec775 improve merging of resolve and parsing options
  • 53a5ae2 Merge pull request #9419 from vankop/remove-valid-jsdoc-rule
  • ab75240 Merge pull request #9413 from webpack/dependabot/npm_and_yarn/ajv-6.10.2
  • 0bdabf4 Merge pull request #9418 from webpack/dependabot/npm_and_yarn/eslint-plugin-jsdoc-15.5.2
  • f207cdc remove valid jsdoc rule in favour of eslint-plugin-jsdoc
  • 31333a6 chore(deps-dev): bump eslint-plugin-jsdoc from 15.3.9 to 15.5.2
  • 036adf0 Merge pull request #9417 from webpack/dependabot/npm_and_yarn/eslint-plugin-jest-22.8.0
  • 37d4480 Merge pull request #9411 from webpack/dependabot/npm_and_yarn/simple-git-1.121.0
  • ce2a183 chore(deps-dev): bump eslint-plugin-jest from 22.7.2 to 22.8.0
  • 0beeb7e Merge pull request #9391 from vankop/create-hash-typescript
  • bf1a24a #9391 resolve super call discussion
  • bd7d95b #9391 resolve discussions, AbstractMethodError
  • 4190638 chore(deps): bump ajv from 6.10.1 to 6.10.2

There are 42 commits in total.

See the full diff

FAQ and help

There is a collection of frequently asked questions. If those don’t help, you can always ask the humans behind Greenkeeper.


Your Greenkeeper Bot 🌴

An in-range update of eslint-plugin-import is breaking the build 🚨

The devDependency eslint-plugin-import was updated from 2.16.0 to 2.17.0.

🚨 View failing branch.

This version is covered by your current version range and after updating it in your project the build failed.

eslint-plugin-import is a devDependency of this project. It might not break your production code or affect downstream projects, but probably breaks your build or test tools, which may prevent deploying or publishing.

Status Details
  • ❌ ci/circleci: test: Your tests failed on CircleCI (Details).
  • βœ… ci/circleci: build: Your tests passed on CircleCI! (Details).

Commits

The new version differs by 61 commits.

  • 0499050 bump to v2.17.0
  • f479635 [webpack] v0.11.1
  • 8a4226d Merge pull request #1320 from bradzacher/export-ts-namespaces
  • 988e12b fix(export): Support typescript namespaces
  • 70c3679 [docs] make rule names consistent
  • 6ab25ea [Tests] skip a TS test in eslint < 4
  • 405900e [Tests] fix tests from #1319
  • 2098797 [fix] export: false positives for typescript type + value export
  • 70a59fe [fix] Fix overwriting of dynamic import() CallExpression
  • e4850df [ExportMap] fix condition for checking if block comment
  • 918567d [fix] namespace: add check for null ExportMap
  • 2d21c4c Merge pull request #1297 from echenley/ech/fix-isBuiltIn-local-aliases
  • 0ff1c83 [dev deps] lock typescript to ~, since it doesn’t follow semver
  • 40bf40a [*] [deps] update resolve
  • 28dd614 Merge pull request #1304 from bradennapier/feature/typescript-export-type

There are 61 commits in total.

See the full diff

FAQ and help

There is a collection of frequently asked questions. If those don’t help, you can always ask the humans behind Greenkeeper.


Your Greenkeeper Bot 🌴

yarn install results in error [email protected]: The engine "node" is incompatible

After doing:

serverless install --url https://github.com/postlight/serverless-babel-starter --name dynathumbs

I get:

yarn install v1.7.0
[1/4] πŸ”  Resolving packages...
[2/4] 🚚  Fetching packages...
error [email protected]: The engine "node" is incompatible with this module. Expected version "^6.14.0 || ^8.10.0 || >=9.10.0".
error Found incompatible module
info Visit https://yarnpkg.com/en/docs/cli/install for documentation about this command.

I running node v9.5.0. I've also tried v8.1.0

An in-range update of serverless is breaking the build 🚨

The devDependency serverless was updated from 1.49.0 to 1.50.0.

🚨 View failing branch.

This version is covered by your current version range and after updating it in your project the build failed.

serverless is a devDependency of this project. It might not break your production code or affect downstream projects, but probably breaks your build or test tools, which may prevent deploying or publishing.

Status Details
  • βœ… ci/circleci: build: Your tests passed on CircleCI! (Details).
  • ❌ ci/circleci: test: Your tests failed on CircleCI (Details).

Release Notes for 1.50.0 (2019-08-14)

Meta

Commits

The new version differs by 123 commits.

  • 210d50c Merge pull request #6540 from serverless/release
  • b4813f1 Release v1.50.0
  • 6effab2 Bump dependencies
  • 312b4f5 Merge pull request #6537 from mthenw/fix-depeloy-individually
  • 896631d Refactor test
  • 6a84748 Merge pull request #6531 from serverless/apigw-logs-setup-fix
  • f0a8b8c Mock npm install in tests
  • 60f36e4 Clear invalid options
  • f2f3c00 Maintain original behavior and add a test
  • 4f43bfd Merge pull request #6534 from onebytegone/fix-remove-extra-lambda-policy-6262
  • ea121e7 Ensure to bail after first fail in CI
  • f781340 typo
  • fe6bab3 Fix prettier issues
  • 3ceb0aa Fix deploy command if package.individually set on a function-level
  • 56d96c4 Only add merged IAM policies for Lambda when they will be used (#6262)

There are 123 commits in total.

See the full diff

FAQ and help

There is a collection of frequently asked questions. If those don’t help, you can always ask the humans behind Greenkeeper.


Your Greenkeeper Bot 🌴

yarn install --frozen-lockfile --non-interactive failed with code 1

Unable to deploy code from my computer

Serverless: Invoke webpack:package
Serverless: Fetch dependency graph from package.json
Serverless: WARNING: Could not determine version of module aws-sdk
Serverless: Package lock found - Using locked versions
Serverless: Packing external modules: typeorm@^0.2.17, aws-sdk
 
  Error --------------------------------------------------
 
  yarn install --frozen-lockfile --non-interactive failed with code 1
 
     For debugging logs, run again after setting the "SLS_DEBUG=*" environment variable.
 
  Stack Trace --------------------------------------------
 
Error: yarn install --frozen-lockfile --non-interactive failed with code 1
    at ChildProcess.child.on.exitCode (node_modules/serverless-webpack/lib/utils.js:92:16)
    at ChildProcess.emit (events.js:189:13)
    at ChildProcess.EventEmitter.emit (domain.js:441:20)
    at maybeClose (internal/child_process.js:970:16)
    at Socket.stream.socket.on (internal/child_process.js:389:11)
    at Socket.emit (events.js:189:13)
    at Socket.EventEmitter.emit (domain.js:441:20)
    at Pipe._handle.close (net.js:597:12)
 
  Get Support --------------------------------------------
     Docs:          docs.serverless.com
     Bugs:          github.com/serverless/serverless/issues
     Issues:        forum.serverless.com
 
  Your Environment Information ---------------------------
     OS:                     darwin
     Node Version:           10.15.3
     Serverless Version:     1.44.1

How use with serverless-env-generator

Hi, i'm using serverless-env-generator to protect my env variables with KMS.
But, I can't use with this boilerplate.

.enviroment.yml

production:
  INSTAGRAM_MAX_ITEMS: '6'
  YOUTUBE_MAX_ITEMS: '6'
dev:
  INSTAGRAM_MAX_ITEMS: '6'
  YOUTUBE_MAX_ITEMS: '6'
staging:
  INSTAGRAM_MAX_ITEMS: '6'
  YOUTUBE_MAX_ITEMS: '6'

serverless.yml

custom:
  webpack:
    webpackConfig: ./webpack.config.js
    packager: 'yarn'
    includeModules:
      forceExclude:
        - aws-sdk
  warmup:
    enabled: true
    events:
      - schedule: rate(5 minutes)
    prewarm: true
    concurrency: 1
  envFiles:
    - environment.yml
  envEncryptionKeyId: ${env:AWS_KMS_KEYID}

plugins:
  - serverless-env-generator
  - serverless-webpack
  - serverless-offline
  - serverless-plugin-warmup
  - serverless-dotenv-plugin

webpack.config.js

const nodeExternals = require('webpack-node-externals')
const slsw = require('serverless-webpack')
const Dotenv = require('dotenv-webpack')

module.exports = {
  entry: slsw.lib.entries,
  target: 'node',
  mode: slsw.lib.webpack.isLocal ? 'development' : 'production',
  externals: [nodeExternals()],
  module: {
    rules: [
      {
        test: /\.tsx?$/,
        use: 'ts-loader',
        exclude: /node_modules/
      },
      {
        test: /\.jsx?$/,
        include: __dirname,
        exclude: /node_modules/,
        use: {
          loader: 'babel-loader'
        }
      }
    ]
  },
  resolve: {
    extensions: ['.tsx', '.ts', '.js', '.jsx']
  },
  plugins: [
    new Dotenv()
  ]
}

lambda.js

import 'dotenv/config'
import { corsSuccessResponse, corsErrorResponse, runWarm } from '../utils'

const handler = async event => {
/* logic */
}
export default runWarm(handler)

Lambda env in console:
image

Could some one help me?

An in-range update of @typescript-eslint/eslint-plugin is breaking the build 🚨

The devDependency @typescript-eslint/eslint-plugin was updated from 2.19.0 to 2.19.1.

🚨 View failing branch.

This version is covered by your current version range and after updating it in your project the build failed.

@typescript-eslint/eslint-plugin is a devDependency of this project. It might not break your production code or affect downstream projects, but probably breaks your build or test tools, which may prevent deploying or publishing.

Status Details
  • ❌ ci/circleci: build: Your tests failed on CircleCI (Details).
  • ❌ ci/circleci: test: Your tests failed on CircleCI (Details).

Release Notes for v2.19.1

2.19.1 (2020-02-10)

Bug Fixes

  • eslint-plugin: [unbound-method] blacklist a few unbound natives (#1562) (4670aab)
  • typescript-estree: ts returning wrong file with project references (#1575) (4c12dac)
Commits

The new version differs by 5 commits.

  • 1c8f0df chore: publish v2.19.1
  • 4c12dac fix(typescript-estree): ts returning wrong file with project references (#1575)
  • e9cf734 docs(eslint-plugin): fix typo in readme
  • 10d86b1 docs(eslint-plugin): [no-dupe-class-members] fix typo (#1566)
  • 4670aab fix(eslint-plugin): [unbound-method] blacklist a few unbound natives (#1562)

See the full diff

FAQ and help

There is a collection of frequently asked questions. If those don’t help, you can always ask the humans behind Greenkeeper.


Your Greenkeeper Bot 🌴

Feature: Invoke Functions

Possible to add support for invoking function locally similar to standard serverless invoke -f functionName

Is there any other way to test this locally without the http event?

`serverless webpack serve` does not work for POST

This may or may not be an issue, but it's not clear how to pass the event object when running a local dev server via yarn serve or serverless webpack serve.

The function below attempts to send an email via sendgrid:

const sg = require('sendgrid')(process.env.SENDGRID_API_KEY);
const helper = require('sendgrid').mail;

const personalization = new helper.Personalization();
const mail = new helper.Mail();

const hello = (event, context, callback) => {

  const content = new helper.Content('text/plain', event.message);
  const emailFrom = new helper.Email(event.email);

  mail.setFrom(emailFrom);
  mail.setSubject(event.subject);
  mail.addContent(content);

  const email = new helper.Email('[email protected]', 'Dillon Bailey');
  personalization.addTo(email);

  mail.addPersonalization(personalization);

  const request = sg.emptyRequest({
    method: 'POST',
    path: '/v3/mail/send',
    body: mail.toJSON(),
  });

  // With promise
  return sg.API(request)
    .then(response => {
      callback(null,  {
        statusCode: response.statusCode,
        body: response,
      });
    })
    .catch(error => {
      // error is an instance of SendGridError
      // The full response is attached to error.response
      callback(error.response,  {
        statusCode: error.response.statusCode,
        body: error.response,
      });
  });
};

export default hello;

The event object this is expecting is something like:

{
  "message": "Test message",
	"email": "[email protected]",
	"subject": "Test Subject"
}

This all works fine when posting that object to the actual API or even when running yarn watch:hello but when running yarn serve and using Postman to POST to http://localhost:8000/hello the response is that message, email and subject are all missing which means the event object is not passed to the function.

Thoughts?

An in-range update of serverless is breaking the build 🚨

The devDependency serverless was updated from 1.58.0 to 1.59.0.

🚨 View failing branch.

This version is covered by your current version range and after updating it in your project the build failed.

serverless is a devDependency of this project. It might not break your production code or affect downstream projects, but probably breaks your build or test tools, which may prevent deploying or publishing.

Status Details
  • ❌ ci/circleci: test: Your tests failed on CircleCI (Details).
  • βœ… ci/circleci: build: Your tests passed on CircleCI! (Details).

Release Notes for 1.59.0 (2019-12-04)

Meta

Commits

The new version differs by 103 commits.

  • 0e5e954 Merge pull request #7046 from serverless/release
  • f87dfbd Release v1.59.0
  • e96b09b Bump dependencies
  • 0bc5014 Merge pull request #7045 from serverless/lambda-provisioned-concurrency
  • 1cf29ff Fix handling of provisionedConcurrency handling
  • 937cd92 Refactor setup of function versioning
  • 4c1cee3 Merge pull request #7044 from serverless/fix-aws-creds-handling
  • 3561687 Fix AWS creds handling
  • f2a41bf Improve tests
  • a45d2a2 Merge pull request #7043 from serverless/lambda-provisioned-concurrency
  • 0347b15 Merge branch 'master' into lambda-provisioned-concurrency
  • e080dd2 Merge pull request #7035 from tinexw/websocket-loglevel
  • 44115aa Merge pull request #7039 from serverless/fix-custom-rest-api-id-handling
  • d28ac9d Merge pull request #6992 from mhart/patch-1
  • 093cd4e Update serverless.yml documentation

There are 103 commits in total.

See the full diff

FAQ and help

There is a collection of frequently asked questions. If those don’t help, you can always ask the humans behind Greenkeeper.


Your Greenkeeper Bot 🌴

An in-range update of @typescript-eslint/eslint-plugin is breaking the build 🚨

The devDependency @typescript-eslint/eslint-plugin was updated from 1.9.0 to 1.10.0.

🚨 View failing branch.

This version is covered by your current version range and after updating it in your project the build failed.

@typescript-eslint/eslint-plugin is a devDependency of this project. It might not break your production code or affect downstream projects, but probably breaks your build or test tools, which may prevent deploying or publishing.

Status Details
  • ❌ ci/circleci: build: Your tests failed on CircleCI (Details).
  • ❌ ci/circleci: test: Your tests failed on CircleCI (Details).

FAQ and help

There is a collection of frequently asked questions. If those don’t help, you can always ask the humans behind Greenkeeper.


Your Greenkeeper Bot 🌴

yarn deploy and sls deploy both lead to issue: unexpected end of JSON input

$ SLS_DEBUG=true sls deploy
Serverless: Load command config
Serverless: Load command config:credentials
Serverless: Load command create
Serverless: Load command install
Serverless: Load command package
Serverless: Load command deploy
Serverless: Load command deploy:function
Serverless: Load command deploy:list
Serverless: Load command deploy:list:functions
Serverless: Load command invoke
Serverless: Load command invoke:local
Serverless: Load command info
Serverless: Load command logs
Serverless: Load command metrics
Serverless: Load command print
Serverless: Load command remove
Serverless: Load command rollback
Serverless: Load command rollback:function
Serverless: Load command slstats
Serverless: Load command plugin
Serverless: Load command plugin
Serverless: Load command plugin:install
Serverless: Load command plugin
Serverless: Load command plugin:uninstall
Serverless: Load command plugin
Serverless: Load command plugin:list
Serverless: Load command plugin
Serverless: Load command plugin:search
Serverless: Load command config
Serverless: Load command config:credentials
Serverless: Load command rollback
Serverless: Load command rollback:function
Serverless: Load command webpack
Serverless: Load command offline
Serverless: Load command offline:start
Serverless: Invoke deploy
Serverless: Invoke package
Serverless: Invoke aws:common:validate
Serverless: Invoke aws:common:cleanupTempDir
Serverless: Invoke webpack:validate
Serverless: Legacy configuration detected. Consider to use "custom.webpack" as object (see README).
Serverless: WARNING: More than one matching handlers found for 'src/hello'. Using 'src/hello.js'.
Serverless: Invoke webpack:compile
Serverless: Bundling with Webpack...
Time: 1180ms
Built at: 03/11/2019 4:39:55 PM
          Asset      Size  Chunks             Chunk Names
src/hello-ts.js  1.47 KiB       0  [emitted]  src/hello-ts
   src/hello.js  1.48 KiB       1  [emitted]  src/hello
Entrypoint src/hello-ts = src/hello-ts.js
Entrypoint src/hello = src/hello.js
[0] ./src/utils/index.ts + 2 modules 1.21 KiB {0} {1} [built]
    | ./src/utils/index.ts 84 bytes [built]
    | ./src/utils/run-warm.ts 345 bytes [built]
    | ./src/utils/lambda-response.ts 814 bytes [built]
[1] ./src/hello-ts.ts 778 bytes {0} [built]
[2] ./src/hello.js 750 bytes {1} [built]
Serverless: Invoke webpack:package

  Syntax Error -------------------------------------------

  Unexpected end of JSON input

     For debugging logs, run again after setting the "SLS_DEBUG=*" environment variable.

  Stack Trace --------------------------------------------

SyntaxError: Unexpected end of JSON input
SyntaxError: Unexpected end of JSON input
    at JSON.parse (<anonymous>)
    at BbPromise.try (/Users/cjiang-ias/sls-boilerplate/node_modules/serverless-webpack/lib/packagers/yarn.js:61:47)
    at tryCatcher (/Users/cjiang-ias/sls-boilerplate/node_modules/bluebird/js/release/util.js:16:23)
    at Function.Promise.attempt.Promise.try (/Users/cjiang-ias/sls-boilerplate/node_modules/bluebird/js/release/method.js:39:29)
    at Utils.spawnProcess.catch.then.then.depJson (/Users/cjiang-ias/sls-boilerplate/node_modules/serverless-webpack/lib/packagers/yarn.js:61:35)
    at tryCatcher (/Users/cjiang-ias/sls-boilerplate/node_modules/bluebird/js/release/util.js:16:23)
    at Promise._settlePromiseFromHandler (/Users/cjiang-ias/sls-boilerplate/node_modules/bluebird/js/release/promise.js:512:31)
    at Promise._settlePromise (/Users/cjiang-ias/sls-boilerplate/node_modules/bluebird/js/release/promise.js:569:18)
    at Promise._settlePromise0 (/Users/cjiang-ias/sls-boilerplate/node_modules/bluebird/js/release/promise.js:614:10)
    at Promise._settlePromises (/Users/cjiang-ias/sls-boilerplate/node_modules/bluebird/js/release/promise.js:693:18)
    at Async._drainQueue (/Users/cjiang-ias/sls-boilerplate/node_modules/bluebird/js/release/async.js:133:16)
    at Async._drainQueues (/Users/cjiang-ias/sls-boilerplate/node_modules/bluebird/js/release/async.js:143:10)
    at Immediate.Async.drainQueues [as _onImmediate] (/Users/cjiang-ias/sls-boilerplate/node_modules/bluebird/js/release/async.js:17:14)
From previous event:
    at PluginManager.invoke (/Users/cjiang-ias/.config/yarn/global/node_modules/serverless/lib/classes/PluginManager.js:407:22)
    at PluginManager.spawn (/Users/cjiang-ias/.config/yarn/global/node_modules/serverless/lib/classes/PluginManager.js:425:17)
    at ServerlessWebpack.BbPromise.bind.then.then.then (/Users/cjiang-ias/sls-boilerplate/node_modules/serverless-webpack/index.js:102:51)
    at runCallback (timers.js:705:18)
    at tryOnImmediate (timers.js:676:5)
    at processImmediate (timers.js:658:5)
    at process.topLevelDomainCallback (domain.js:121:23)

  Get Support --------------------------------------------
     Docs:          docs.serverless.com
     Bugs:          github.com/serverless/serverless/issues
     Issues:        forum.serverless.com

  Your Environment Information -----------------------------
     OS:                     darwin
     Node Version:           10.13.0
     Serverless Version:     1.38.0

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.