Skip to content

Instantly share code, notes, and snippets.

View zeyneloz's full-sized avatar

zeynel ozdemir zeyneloz

View GitHub Profile
exports.handler = async (event) => {
await sendMail(event.to, event.subject, event.message);
return { success: true };
};
exports.handler = async (event) => {
const notes = await getNotes(user.id); // Fetch user notes from database.
const translatedNotes = await translate(notes, event.translateTo); // Translate notes to target language.
await sendMail(user.email, "Your notes", translatedNotes); // Send translated notes to user.
return { message: "You will receive the email soon" };
};
exports.handler = async (event) => {
const translation = await translate(event.text, event.language);
return { text: translation };
};
{
"StartAt": "translateTask",
"Comment": "exportNotes workflow.",
"Version": "1.0",
"States": {
"translateTask": {
"Type": "Task",
"Resource": "arn:aws:lambda:x:x:function:translate",
"Next": "sendMailTask",
},
{
"StartAt": "translateTask",
"Comment": "exportNotes workflow.",
"Version": "1.0",
"States": {
"translateTask": {
"Type": "Task",
"Resource": "arn:aws:lambda:x:x:function:translate",
"Next": "adapter",
"InputPath": "$.translateInput",
const AWS = require('aws-sdk');
const stepFunctions = new AWS.StepFunctions({});
exports.handler = async (event) => {
const notes = await getNotes(user.id); // Fetch user notes from database.
const sfnInput = { // Prepare Step Functions input
translateInput: { // translate Task will use this input.
text: notes,
language: event.translateTo
},
exports.handler = async (event) => {
// Convert translate lambda output to sendMail lambda input.
event.sendMailInput.message = event.translateOutput.text;
return event;
};
package main
import (
"encoding/json"
"io/ioutil"
"log"
"net/http"
)
type loginSchema struct {
package main
import (
"encoding/json"
"fmt"
"io/ioutil"
"log"
"net/http"
)
// ClientError is an error whose details to be shared with client.
type ClientError interface {
Error() string
// ResponseBody returns response body.
ResponseBody() ([]byte, error)
// ResponseHeaders returns http status code and headers.
ResponseHeaders() (int, map[string]string)
}