Skip to content
This repository was archived by the owner on Oct 21, 2022. It is now read-only.

Latest commit

 

History

History
141 lines (89 loc) · 3.57 KB

File metadata and controls

141 lines (89 loc) · 3.57 KB

Table of Contents

getPublications

Lambda function getPublications

Method: GET

Validates the origin URL with safeGetHeaders

Endpoints

Parameters

Examples

// Call locally from the CLI:
DEBUG=true npx sls invoke local --function getPublications --path test/staticSiteMailer-dummy-payload.json

// Expected payload
{
  "headers": {
     "origin": "ORIGIN"
  },
  "body": "[ { id: "123", "title": "My Post" } ]",
}

Returns Promise<void> Nothing is returned, AWS callback is used instead

staticSiteMailer

Lambda function staticSiteMailer

Method: POST

Expected fields:

  • name {string}
  • email {string}
  • message {string}

Validates the origin URL with safeGetHeaders

Endpoints

Envars that need to be set: process.env.STATIC_SITE_MAILER_SOURCE; process.env.STATIC_SITE_MAILER_DESTINATION;

Both mail addresses need to be validated in AWS SES

Parameters

Examples

// Call locally from the CLI:
STATIC_SITE_MAILER_SOURCE=example@example.com STATIC_SITE_MAILER_DESTINATION=example@example.com DEBUG=true npx sls invoke local --function staticSiteMailer --path test/staticSiteMailer-dummy-payload.json

// Expected payload
{
  "headers": {
     "origin": "ORIGIN"
  },
  "body": "{\"name\": \"Sender Name\",\"email\": \"sender@example.com\",\"message\": \"This is a dummy message to test the contact form\",\"phone\": \"123\"}",
}

Returns Promise<void> Nothing is returned, AWS callback is used instead

safeGetHeaders

Gets reponse headers but throws error if the requesting origin is not whitelisted. This must be done before anything else to prevent calls from unknown origins.

Parameters

  • origin string URL describing the origin of the call

Returns Object headers