Cosmic JS Function Starter
Switch branches/tags
Nothing to show
Clone or download
Latest commit bdb50a9 Sep 10, 2018
Permalink
Failed to load latest commit information.
.gitignore fix get issue in Postman Aug 27, 2018
README.md Update README.md Sep 10, 2018
function.json route options Aug 26, 2018
index.dev.js envent body stringify Aug 26, 2018
index.js fix get issue in Postman Aug 27, 2018
package-lock.json route options Aug 26, 2018
package.json route options Aug 26, 2018

README.md

Function Starter

Cosmic JS Function Starter.

Getting Started

You can run this Function locally for development:

git clone https://github.com/cosmicjs/function-starter
cd function-starter
npm install
npm run develop

Installation

  1. Login to Cosmic JS and go to Your Bucket > Settings > Functions
  2. Add the link to this repo: https://github.com/cosmicjs/function-starter and click "Install Function"

function.json file properties

Key Type Description
title String Function title
description String Function description (HTML allowed)
image_url String Image thumbnail
repo_url String Function git repo url
env_vars Array key / value for environment variables
routes Array Function routes: properties include path (string), method (string) and cors (bool)

Example function.json file:

{
  "title": "Function Starter",
  "description": "Cosmic JS Function starter.",
  "image_url": "https://cosmicjs.com/images/marketing/logo-w-brand.jpg",
  "repo_url": "https://github.com/cosmicjs/function-starter",
  "env_vars": [
    {
      "key": "CUSTOM_MESSAGE",
      "value": ""
    }
  ],
  "routes": [
    {
      "path": "hello-world",
      "method": "get",
      "cors": true
    }
  ]
}