JSPM

serverless-commercetools-plugin

1.1.8
    • ESM via JSPM
    • ES Module Entrypoint
    • Export Map
    • Keywords
    • License
    • Repository URL
    • TypeScript Types
    • README
    • Created
    • Published
    • Downloads 42
    • Score
      100M100P100Q50929F
    • License MIT

    Serverless framework plugin that registers the deployed function as a commercetools API Extension or attaches it to a Subscription.

    Package Exports

    • serverless-commercetools-plugin

    This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (serverless-commercetools-plugin) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

    Readme

    commercetools Serverless Plugin

    commercetools's plugin for the Serverless Framework allows you to seamlessly integrate your serverless functions with commercetools' extensibility options.

    Contents

    Features

    • Attach a newly deployed serverless function as a commercetools' API extension.
    • Create a new serverless function to process events from a commercetools' subscription.
    • Supports AWS and GCP

    Install

    npm i --save-dev serverless-commercetools-plugin
    # or
    yarn add --dev serverless-commercetools-plugin

    Add the following plugin to your serverless.yml:

    plugins:
      - serverless-commercetools-plugin

    With the serverless CLI

    serverless plugin install --name serverless-commercetools-plugin

    Configuration

    Add your commercetools' project settings to the serverless.yaml file. Add these values under the provider section:

    provider:
      environment:
        CTP_PROJECT_KEY: "your_key"
        CTP_CLIENT_SECRET: "your_secret"
        CTP_CLIENT_ID: "your_clientid"
        CTP_AUTH_URL: "your_authurl"
        CTP_API_URL: "your_apiUrl"
        CTP_SCOPES: "your_scopes"

    API Extension

    Add environment vars for the deploy type ("extension") and your body configuration for the Extension.

        CTP_DEPLOY_TYPE: "extension"
        CTP_POST_BODY: '{
            "destination": {
              "type": "AWSLambda",
              "accessKey": "your_aws_key",
              "accessSecret": "your_aws_secret"
            },
            "triggers": [{
              "resourceTypeId": "cart",
              "actions": ["Create", "Update"]
            }]
        }'

    Note: The Lambda ARN is determined by the plugin. You do not need to include it in the configuration.

    For Google Cloud Platform functions set the CTP_POST_BODY to use the HTTP destination as outlined in the commercetools API Extension documentation.

    Subscription

    Add environment vars for the deploy type ("subscription") and your body configuration for the Subscription.

        CTP_DEPLOY_TYPE: "extension"
        CTP_POST_BODY: '{
            "destination": {
              "type": "AWSLambda",
              "accessKey": "your_aws_key",
              "accessSecret": "your_aws_secret"
            },
            "triggers": [{
              "resourceTypeId": "cart",
              "actions": ["Create", "Update"]
            }]
        }'

    Usage

    To build your cloud resources and configure the commercetools' project run:

    serverless deploy

    To remove all cloud resources and commercetools' configuration run:

    serverless remove

    Help

    If you have any issues, please don't hesitate to:

    When opening a new issue, please provide as much information as possible including:

    • Plugin version
    • node version
    • cloud environment
    • A reproducible code example

    The GitHub issues are intended for bug reports and feature requests specifically related to the serverless plugin.

    Development

    Create a local serverless function or copy the code from the examples folder. Add the plugin code to a folder named .serverless_plugins at the root of your serverless project.

    License

    Released as-is under the MIT license. See LICENSE for details.