7.0.7 • Published 4 years ago

@mineko/lambda-core v7.0.7

Weekly downloads
-
License
MIT
Repository
bitbucket
Last release
4 years ago

Lambda Core

Formerly know as lambda-basics which was a open-source project. This module provides a set of useful functions for lambda.

Install

npm i -S @mineko/lambda-core

peer dependency

This library needs tsyringe to work. tsyringe is defined as peer dependency to prevent multiple DI containers (as every installation would get loaded). Please take this into account when you setup your project's build process.

When your are using webpack to build your project:

Usage with webpack

Add following to your webpack.config.js

resolve: {
    extensions: ['.js', '.ts', '.json'],
    modules: [
        path.join(__dirname, 'node_modules'), 'node_modules', //this line will first try to resolve dependencies in your projects node_modules folder
    ],
},

As well consider to use ts-loader:

  module: {
    rules: [
      {
        test: /\.(ts|tsx)$/,
        loader: 'ts-loader',
      },
    ],
  },

Usage

For each class a instance is as well exported (except for LoggerInstance as Logger is defined in another project). You can either use ready to use instances or use it in your own dependency framework.

LoggerInstance

See js-core for description.

Runtime / RuntimeInstance

Pass an lambda event and a callback to Runtime.execute(callback, event) and it will automatically wrap it in a try catch block and will check if it's a warm-up event. It will call the callback injecting the event return callback(event) and returning the callback result.

Usage

const handler = async (event) => {
    return 'something';
}

exports.handler = async event => {
    return RuntimeInstance.execute(handler, event);
}

SSMParameter / SSMParameterInstance

  • getValue(name) Will return the value of an ssm parameter

ApiGatewayHeader / ApiGatewayHeaderInstance

  • get(event, headerKey): Will return the header value of event for key headerKey case insensitive

OAuth / OAuthInstance

  • getAccessToken(endpoint, clientId, clientSecret): Will return the response of an endpoint to get an access token following OAuth client credentials flow

Validate / ValidateInstance

  • requestParams(requiredParams)(requestParams): Will return a function which will check if params contains requiredParams

ResponseHandler / ResponseHandlerInstance

  • getResponseObject(statusCode, headers, body): Will return a response object where the body is json string
  • getErrorResponseBody(message, type): Wil lreturn a error response body
7.0.7

4 years ago

7.0.6

4 years ago

7.0.5

4 years ago

7.0.4

4 years ago

7.0.3

4 years ago

7.0.2

4 years ago

5.1.4

4 years ago

6.0.0

4 years ago

5.1.6

4 years ago

5.1.3

4 years ago

5.1.2

4 years ago

5.1.1

4 years ago

5.0.2

4 years ago

5.1.0

4 years ago

5.0.1

4 years ago

5.0.0

4 years ago

4.4.1

4 years ago

4.4.0

4 years ago

4.3.0

4 years ago

4.2.1

4 years ago

4.2.0

4 years ago

4.1.3

4 years ago

4.1.2

5 years ago

4.1.1

5 years ago

4.1.0

5 years ago

4.0.7

5 years ago

4.0.6

5 years ago

4.0.5

5 years ago

4.0.4

5 years ago

4.0.3

5 years ago

4.0.2

5 years ago

4.0.1

5 years ago

4.0.0

5 years ago

3.6.0

5 years ago

3.5.1

5 years ago

3.4.1

5 years ago

3.4.0

5 years ago

3.3.1

5 years ago

3.3.0

5 years ago

3.2.0

5 years ago

3.1.2

5 years ago

3.1.1

5 years ago

3.1.0

5 years ago

3.0.2

5 years ago

3.0.1

5 years ago

3.0.0

5 years ago

2.4.2

5 years ago

2.4.1

5 years ago

2.4.0

5 years ago

2.3.0

5 years ago

2.2.0

5 years ago

2.1.0

5 years ago

2.0.5

5 years ago

2.0.4

5 years ago

2.0.3

5 years ago

2.0.2

5 years ago