GithubHelp home page GithubHelp logo

example-projects's Introduction

Claudia.js Example projects

Hello world

  • Hello World – shows a trivial Node.js Lambda function and how to set up deployment using Claudia.js
  • Web API – a simple REST api, shows how to configure and deploy an API Gateway interface along with the Lambda function

Common Development tasks

  • Using NPM Modules – a slightly more complex function, shows how to deploy third party dependencies using Claudia.js
  • Using Babel – shows how to deploy transpiled Babel code
  • Environment Variables – setting and using Lambda environment variables
  • Detecting Context – detect if a function was called for development or production, in order to load the right configuration
  • Recursive invocation – an example of how Lambda can asynchronously call itself to work around timing limitations
  • Packing for AWS SAM – an example of how to use Claudia to prepare packages for deployment using CloudFormation and AWS SAM

Web API

  • Web Serving HTML – shows how to change error and success content types and response codes, and how to perform browser redirects
  • Generic handlers – shows how to capture dynamic paths and set up handlers for any content type easily
  • Custom response codes – shows how to change status codes for response
  • Custom Headers – shows how to return custom headers from API responses
  • Custom CORS origins – shows how to control allowed CORS origins/headers
  • Intercepting requests – an example showing how to prevent or modify requests
  • Post-deploy variable configuration – shows how to set up post-deploy hooks to prompt users for stage variables
  • Generic post-deploy steps – shows how to set up post-deploy hooks for automatic configuration
  • Using Lambda Context – shows how to access the Lambda Context object from projects built using claudia-api-builder
  • DynamoDB CRUD – a simple document store, shows how to use DynamoDB and connect it to a CRUD REST API. Also shows how to configure a single Lambda function to work with different resources for development, testing and production.
  • GraphQL Endpoint – GraphQL CRUD operations, using DynamoDB for persistence.
  • GitHub Repository Labels – a simple image server, shows how to map URL path components to arguments, how to customise response types and how to connect to third party REST APIs
  • Using AWS Mobile Analytics for server-side events – log events into AWS Mobile Analytics for easy internal telemetry
  • Custom Authorizers – a simple example of how to set up custom authorizers in API Gateway
  • Geo location – shows how to retrieve the country where your users originated the request
  • Binary Content – shows how to configure API Gateway to send or receive binary data
  • Twilio & Shippo webhook – shows how to create an API endpoint for processing webhook updates using Twilio and Shippo

Event processing

  • S3 File Processing – an example service that converts files uploaded to S3; shows how to wire up Lambda to respond to S3 events
  • IOT Topic Filters – an example how to trigger a function when a message is posted to an IOT Data Topic
  • Pandoc S3 Converter – a more complex example that converts S3 files to .docx using Pandoc
  • SVG to PDF S3 Converter – convert SVG files uploaded to S3 to PDF format using RSVG and Cairo
  • Website Email Alert – periodically check a URL and send an e-mail if it is not available; shows how to send e-mails using SES and set up Lambda functions as scheduled recurring events

Proxy API

Chat-bots

  • Simple Bot – an example demonstrating how to receive and respond with simple text messages
  • Facebook Messenger Bot with Buttons – an example showing how to create more complex platform specific messages, for example Facebook buttons
  • Space Explorer Bot – uses NASA's API to get the data and images about the space, shows how to use Facebook Template builders for response messages.
  • Slack Delayed Reply – an example showing how to send delayed and multiple replies for Slack slash commands.
  • Alexa Skill – an Amazon Echo (Alexa) skill sample that spells out English words

Examples in other repositories

More information

For more information on the Web API configuration syntax, check out the Claudia API Builder project. For more information on Claudia.js options, see the Command Line Usage.

Join the chat at https://gitter.im/claudiajs/claudia

Prerequisites

To get started, make sure your credentials are configured. See the ClaudiaJS Getting Started Guide for more information.

AWS Lambda currently runs Node.js version 10 and 8 (you can choose the runtime with --runtime when creating the function). It's best to use the same version for testing and deployment.

example-projects's People

Contributors

adrai avatar bryant1410 avatar gojko avatar joaojeronimo avatar marcusoftnet avatar mootrichard avatar rickyk586 avatar sgtpooki avatar simalexan avatar stojanovic avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

example-projects's Issues

Selective Intercepts

Can I apply the intercept only to some routes? In the example, it looks like it works differently from express middleware, in the sense that it is applied to all routes above it. Does it apply also to all routes written below? Thanks!

How to run web-api project locally?

I was testing the web-api project example and I was able to deployed into AWS API Gateway/ Lambda successfully.

Anyway, I was wondering if there is any way to run this example locally?

Thanks in advance

Repo-label example project badge is not rendering in the README

Probably because repolabels.net currently does not output Access-Control-Allow-Origin: * in the svg response headers. Since GitHub now proxies all image traffic through camo.githubusercontent.com, some CORS access control (such as the line above) is going to be necessary for allowing SVGs to render in READMEs.

claudia create --region us-east-1 --api-module bot --configure-fb-bot command fails

Use the Claudia.js Gitter Chat instead to ask a general question or request assistance/support.

Please use GitHub issues only to report bugs with example projects. To report a bug or a problem, please fill in the sections below. The more you provide, the better we'll be able to help.


  • Expected behaviour:

  • What actually happens:
    getting this error initialising IAM role iam.createRole RoleName=guidable-bot-executor
    { TimeoutError: Missing credentials in config
    not sure how to or where to add these credentials been searching for this info for hours. I'm guessing it's referring to some amazon AWS credentials ?

  • Link to a minimal, executable project that demonstrates the problem:

  • Steps to install the project:

  • Steps to reproduce the problem:

How to serve jade/pug template?

Use the Claudia.js Gitter Chat instead to ask a general question or request assistance/support.

Please use GitHub issues only to report bugs with example projects. To report a bug or a problem, please fill in the sections below. The more you provide, the better we'll be able to help.


  • Expected behaviour:

  • What actually happens:

  • Link to a minimal, executable project that demonstrates the problem:

  • Steps to install the project:

  • Steps to reproduce the problem:

web-api-custom-headers example is misleading

Hi there, thanks for putting this project together - makes it significantly easier to build a web API on top of Lambda. 👏

I ran into an issue using the customer headers in the web-api-custom-headers example.

Specifically, the example shows passing a custom header for "Content-Type", which led me to believe this was the way to set the content type of a response. Unfortunately, this causes Lambda to send quoted responses.

For example

"this is some\ntext"

instead of

this is some
text

After looking at the web-serving-html example, I noticed a special contentType parameter. When using that, the responses are unquoted, as expected.

I would recommend making it clear somewhere of this behavior, or updating the custom headers example to use the contentType parameter - it was pretty confusing and took a while to track down what was going on.

Alexa example which url?

When I run

npm run create

I get back something like this:


{
  "lambda": {
    "role": "alexa-spell2-executor",
    "name": "alexa-spell2",
    "region": "us-east-1"
  },
  "api": {
    "id": "xyxyxy",
    "module": "bot",
    "url": "https://xyxyxy.execute-api.us-east-1.amazonaws.com/latest",
    "deploy": {
      "alexa": "https://xyxyxy.execute-api.us-east-1.amazonaws.com/latest/alexa"
    }
  }
}

Which url should I be using https://xyxyxy.execute-api.us-east-1.amazonaws.com/latest/alexa?

I try both and get back:

The remote endpoint could not be called, or the response it returned was invalid.

screenshot_2017-02-16_16-01-11

claudia update fails with latest fastify version

TypeError: "listener" argument must be a function
    at _addListener (events.js:239:11)
    at Server.addListener (events.js:297:10)
    at new Server (_http_server.js:269:10)
    at Object.createServer (http.js:34:10)

express-app-lambda doesn't work - Cannot GET /claudia-test

I want to see Claudia act as a express wrapper. The example doesn't work. Below are the files:

lambda.js
'use strict'
const awsServerlessExpress = require('aws-serverless-express')
const app = require('./app')
const binaryMimeTypes = [
'application/octet-stream',
'font/eot',
'font/opentype',
'font/otf',
'image/jpeg',
'image/png',
'image/svg+xml'
]
const server = awsServerlessExpress.createServer(app, null, binaryMimeTypes);
exports.handler = (event, context) => awsServerlessExpress.proxy(server, event, context)

app.js
'use strict'
const express = require('express')
const app = express()

app.get('/', (req, res) => res.send('Hello World!')); // I simplified this line
// app.listen(3000) // <-- comment this line out from your app
module.exports = app // export your app so aws-serverless-express can use it


I am getting blank response. i want to use node-twitter-api package in claudia. how can i use it.

   var ApiBuilder = require('claudia-api-builder'),
   api = new ApiBuilder();
   var Twitter = require('twitter');    
   var twitterAPI = require('node-twitter-api');
   var path = require('path');
   var jsonfile = require('jsonfile')
   var url = require('url');
   var superb = require('superb');
   var Promise = require("bluebird");
   
   api.get("/request-token", function(request) {
        'use strict';
        var file = 'secret.json';
        var secret = 1;
        jsonfile.readFile(file, function(err, obj) {
        console.log("err: "+err);
        console.log("json: "+obj);
        secret = obj;
        });
        new Promise(function (resolve) {
            var twitter = new twitterAPI({
                consumerKey: "ckey",
                consumerSecret: "cskey",
                callback: 'http://localhost:3000/access-token'
            });
            var res;
            twitter.getRequestToken(function(err, requestToken, requestSecret) {
                console.log("err "+JSON.stringify(err));
                console.log("requestToken "+JSON.stringify(requestToken));
                if (err)
                    res = err;
                else {
                    var _requestSecret = requestSecret;
                    console.log("key "+secret.twitter.consumer_key);
                    console.log("url: "+url);
                    var url = "https://twitter.com/oauth/authenticate?oauth_token"+requestToken;
                    res = url;
                    //console.log(twitter.getAuthUrl(requestToken));
                    //res.redirect(url);
                }
            });
            return res;
        });
    });

are the cors overrides working?

Use the Claudia.js Gitter Chat instead to ask a general question or request assistance/support.

Please use GitHub issues only to report bugs with example projects. To report a bug or a problem, please fill in the sections below. The more you provide, the better we'll be able to help.


  • Expected behaviour:
    using some of the cors override behaviour as described here: https://github.com/claudiajs/claudia-api-builder/blob/master/docs/cors.md should override the cors headers.

  • What actually happens:
    whatever method I use the cors headers never change.
    This is the output whatever I change:
    { "StatusCode": 200, "ExecutedVersion": "$LATEST", "Payload": "{\"statusCode\":200,\"headers\":{\"Content-Type\":\"application/json\",\"Access-Control-Allow-Origin\":\"*\",\"Access-Control-Allow-Headers\":\"Content-Type,Authorization,X-Amz-Date,X-Api-Key,X-Amz-Security-Token\",\"Access-Control-Allow-Methods\":\"GET,POST,OPTIONS\",\"Access-Control-Allow-Credentials\":\"true\",\"Access-Control-Max-Age\":\"0\"},\"body\":\"{\\\"info\\\":\\\"test\\\"}\"}" }

  • Link to a minimal, executable project that demonstrates the problem:
    add the line:
    api.corsOrigin(false)
    into the example tutorial and the cors headers still come through as all allowed

  • Steps to install the project:

  • Steps to reproduce the problem:

s3-file-processing won't work - aws-sdk dependency is missing locally

XXX> npm start

> s3-file-procesing@ start XXX
> claudia create --name s3-processing --region us-east-1 --handler main.handler

validating package
Error: Cannot find module 'aws-sdk'
    at Function.Module._resolveFilename (module.js:336:15)
    at Function.Module._load (module.js:286:25)
...

I guess the fix is to either suggest manually installing the aws-sdk, or add it to packages.json? If it was clear to me which one i could send a PR

Pass custom headers through Amazon API Gateway

Hi Team!

How to pass custom headers through Amazon API Gateway with ClaudiaJS?

A POST route built with ApiBuilder does not receive natively the custom headers.
An external provider realizes a POST every minute to an endpoint of our API Gateway. This provider offers important information only as POST Headers. These information changes at every POST. I need to access these custom headers values in the Lambda...

It's about configuring the Request Headers, not the Response headers ;)

Any help much appreciated...

Error on npm start

using [email protected]
using [email protected]

I was testing out web-api-test project after i do "npm install" and then follow it by "npm start"
which runs "claudia create --name web-api-test --region us-east-1 --api-module web" it results in an error.

`> claudia create --name web-api-test --region us-east-1 --api-module web

packaging files npm pack /Users//Code/Bots/SMSBotApi
npm pack /Users//Code/Bots/SMSBotApi failed. Check /var/folders/ls/fhnr088j0dbgw3p7zrk7g5c80000gq/T/798a05c1-fc09-47e5-852d-290f2e166000

npm ERR! Darwin 16.0.0
npm ERR! argv "/usr/local/bin/node" "/usr/local/bin/npm" "start"
npm ERR! node v4.2.6
npm ERR! npm v2.14.12
npm ERR! code ELIFECYCLE
npm ERR! web-api-test@ start: claudia create --name web-api-test --region us-east-1 --api-module web
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the web-api-test@ start script 'claudia create --name web-api-test --region us-east-1 --api-module web'.
npm ERR! This is most likely a problem with the web-api-test package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR! claudia create --name web-api-test --region us-east-1 --api-module web
npm ERR! You can get their info via:
npm ERR! npm owner ls web-api-test
npm ERR! There is likely additional logging output above.`

This is working fine with previous versions of claudia (2.0.0) and claudia api builder (2.0.0) but not with claudia api builder 2.0.2 and claudia 2.1.2

Do I have to upgrade nodejs and npm? are there any minimum requirements?

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.