Coder Social home page Coder Social logo

seratch / bolt-aws-lambda-proof-of-concept Goto Github PK

View Code? Open in Web Editor NEW
8.0 3.0 1.0 18 KB

This repository was created in the aim of demonstrating the possibilities of proper FaaS (AWS Lambda, Google Cloud Functions etc) environment support by Bolt.

Home Page: https://github.com/slackapi/bolt/issues/361

TypeScript 98.99% JavaScript 1.01%

bolt-aws-lambda-proof-of-concept's Introduction

@slack/bolt-aws-lambda prototype

This repository was created in the aim of demonstrating the possibilities of proper FaaS (AWS Lambda, Google Cloud Functions etc) environment support by Bolt. As of December 2019, there is no plan to merge this implementation into Bolt framework.

How it works

import { AwsLambdaReceiver } from './src/added/AwsLambdaReceiver';
import { TwoPhaseApp } from './src/added/TwoPhaseApp';
import { sleep } from './src/added/helpers';

const app = new TwoPhaseApp({
  token: process.env.SLACK_BOT_TOKEN,
  receiver: new AwsLambdaReceiver({
    signingSecret: process.env.SLACK_SIGNING_SECRET
  })
});

app.command('/lambda')
  .ack(({ ack }) => {
    ack('ack response');
  })
  .then(async ({ body, say }) => {
    app.logger.info("You are here after the acknowledgement...");
    let totalMillis = 0;
    while (totalMillis < 5000) { // sleep for 5 seconds
      totalMillis += 1000;
      await sleep(1000);
      app.logger.info('Sleeping...');
    }
    app.logger.info("Let's go!");
    return say('How are you?').then(() => say("I'm good!"));
  });

export const main = app.receiver().toHandler();

demo

Run the app on your local machine

cp _env .env
# edit .env
npm i
npm i serverless -g
sls offline --printOutput

Deploy the app onto AWS

export SLACK_BOT_TOKEN=xoxb-xxxxxxxxx
export SLACK_SIGNING_SECRET=xxxxxxxxx
export SERVERLESS_STAGE=dev
sls deploy --stage ${SERVERLESS_STAGE} -v

bolt-aws-lambda-proof-of-concept's People

Contributors

seratch avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Forkers

tkimi

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.