Giter VIP home page Giter VIP logo

realworld-dynamodb-lambda's Introduction

RealWorld Example App

RealWorld Backend Build Status Coverage Status Greenkeeper badge Known Vulnerabilities Gitter

AWS DynamoDB + Lambda codebase containing real world examples (CRUD, auth, advanced patterns, etc) that adheres to the RealWorld spec and API.

This codebase was created to demonstrate a fully fledged fullstack application built with AWS DynamoDB + Lambda including CRUD operations, authentication, routing, pagination, and more.

We've gone to great lengths to adhere to the AWS DynamoDB + Lambda community styleguides & best practices.

For more information on how to this works with other frontends/backends, head over to the RealWorld repo.

Getting started

Requires Node 8 or higher

Clone this repo, and cd into it:

git clone https://github.com/anishkny/realworld-dynamodb-lambda
cd realworld-dynamodb-lambda

Starting the local server

npm install
npm run start

This should start local DynamoDB emulator and Serverless offline. You can now make API calls against http://localhost:3000/api like this:

curl http://localhost:3000/api/articles

Serverless: GET /api/articles (λ: listArticles)
Serverless: The first request might take a few extra seconds
Serverless: [200] {"statusCode":200,"headers":{"Access-Control-Allow-Origin":"*","Access-Control-Allow-Credentials":true},"body":"{\"articles\":[]}"}

Running tests locally

npm test

See sample test run log and network traffic.

How it works

Overview

This repo uses Serverless Framework to describe, test and deploy the RealWorld REST API to AWS Lambda. AWS Lambda provides "serverless" cloud functions as a service. AWS API Gateway is used to expose the deployed Lambda functions as a HTTP REST API.

Architecture Diagram

API

The API is described in the serverless.yml file. For example the following snippet instructs AWS Lambda to execute the create method in src/User.js whenever a POST method is called on /api/users:

functions:

  ## Users API
  createUser:
    handler: src/User.create
    events:
      - http:
          method: POST
          path: /api/users
          cors: true

  ...

Storage

For storage, AWS DynamoDB a managed serverless NoSQL database is used. Tables are created to store users, articles and comments also described in serverless.yml file. For example:

resources:
  Resources:

    UsersDynamoDBTable:
      Type: 'AWS::DynamoDB::Table'
      DeletionPolicy: Retain
      Properties:
        AttributeDefinitions:
        ...

Deployment

To deploy the code to AWS, simply execute:

npm run deploy

This will use serverless to deploy the API as described in serverless.yml.

Once deployed, you can test the deployed API by executing:

npm run test:deployed

realworld-dynamodb-lambda's People

Contributors

anishkny avatar artoliukkonen avatar bryanjenningz avatar cameron-c-chapman avatar ericsimons avatar greenkeeper[bot] 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

realworld-dynamodb-lambda's Issues

Running locally, after login getting article feed gives 422 error

Yarn: 1.12.3
Node: v8.11.1
Commands:

Serverless: POST /api/users/login (λ: loginUser)
Serverless: [200] {"statusCode":200,"headers":{"Access-Control-Allow-Origin":"*","Access-Control-Allow-Credentials":true},"body":"{\n  \"user\": {\n    \"email\": \"[email protected]\",\n    \"token\": \"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VybmFtZSI6ImV3cXdxQGRhc2RzLmNvbSIsImlhdCI6MTU1NjIyMDUzOSwiZXhwIjoxNTU2MzkzMzM5fQ.WECLRpuNucNatUBay96ucZ5hq1APZ4zle9RrAFtpsAg\",\n    \"username\": \"[email protected]\",\n    \"bio\": \"\",\n    \"image\": \"\"\n  }\n}"}

Serverless: GET /api/tags (λ: getTags)

Serverless: GET /api/articles/feed (λ: getArticlesFeed)
Serverless: [422] {"statusCode":422,"headers":{"Access-Control-Allow-Origin":"*","Access-Control-Allow-Credentials":true},"body":"{\n  \"errors\": {\n    \"body\": [\n      \"Must be logged in.\"\n    ]\n  }\n}"}
Serverless: [200] {"statusCode":200,"headers":{"Access-Control-Allow-Origin":"*","Access-Control-Allow-Credentials":true},"body":"{\n  \"tags\": []\n}"}

Serverless: GET /api/user (λ: getUser)
Serverless: [422] {"statusCode":422,"headers":{"Access-Control-Allow-Origin":"*","Access-Control-Allow-Credentials":true},"body":"{\n  \"errors\": {\n    \"body\": [\n      \"Token not present or invalid.\"\n    ]\n  }\n}"}

An in-range update of serverless-dynamodb-local is breaking the build 🚨

The devDependency serverless-dynamodb-local was updated from 0.2.35 to 0.2.36.

🚨 View failing branch.

This version is covered by your current version range and after updating it in your project the build failed.

serverless-dynamodb-local is a devDependency of this project. It might not break your production code or affect downstream projects, but probably breaks your build or test tools, which may prevent deploying or publishing.

Status Details
  • continuous-integration/travis-ci/push: The Travis CI build failed (Details).

FAQ and help

There is a collection of frequently asked questions. If those don’t help, you can always ask the humans behind Greenkeeper.


Your Greenkeeper Bot 🌴

Enable development on Windows

> [email protected] postinstall C:\Users\deept\Documents\Node\realworld-dynamodb-lambda
> serverless dynamodb install 2>&1 | awk 'NF'

awk: 'NF'
awk: ^ invalid char ''' in expression

Is there any way to make this work on windows? I suspect its the single speech marks.

TypeError: Cannot read property 'status' of undefined at MochaAxiosReporter.axios.interceptors.response.use (test/mocha-axios-reporter.js:34:27)

Sporadically occurs.

E.g. https://travis-ci.org/anishkny/realworld-dynamodb-lambda/jobs/401011370

  1) "before all" hook:
     TypeError: Cannot read property 'status' of undefined
      at MochaAxiosReporter.axios.interceptors.response.use (test/mocha-axios-reporter.js:34:27)
      at <anonymous>
      at process._tickCallback (internal/process/next_tick.js:188:7)

`${error.response.status} ${error.response.statusText}\n\n` +

Question: serverless dynamo local data

Hi

I am new with dynamo, when I restart this project the previous data are lost...there are some way to keep my local data during development?? In building a several tables, is realy hard to fill al tables when the services is restarted.
I hope that you can help me.

regards

PS: sorry for ignorance if the answer is obvious, it is overwhelming to absorb so much knowledge so fast

Version 10 of node.js has been released

Version 10 of Node.js (code name Dubnium) has been released! 🎊

To see what happens to your code in Node.js 10, Greenkeeper has created a branch with the following changes:

  • Added the new Node.js version to your .travis.yml

If you’re interested in upgrading this repo to Node.js 10, you can open a PR with these changes. Please note that this issue is just intended as a friendly reminder and the PR as a possible starting point for getting your code running on Node.js 10.

More information on this issue

Greenkeeper has checked the engines key in any package.json file, the .nvmrc file, and the .travis.yml file, if present.

  • engines was only updated if it defined a single version, not a range.
  • .nvmrc was updated to Node.js 10
  • .travis.yml was only changed if there was a root-level node_js that didn’t already include Node.js 10, such as node or lts/*. In this case, the new version was appended to the list. We didn’t touch job or matrix configurations because these tend to be quite specific and complex, and it’s difficult to infer what the intentions were.

For many simpler .travis.yml configurations, this PR should suffice as-is, but depending on what you’re doing it may require additional work or may not be applicable at all. We’re also aware that you may have good reasons to not update to Node.js 10, which is why this was sent as an issue and not a pull request. Feel free to delete it without comment, I’m a humble robot and won’t feel rejected 🤖


FAQ and help

There is a collection of frequently asked questions. If those don’t help, you can always ask the humans behind Greenkeeper.


Your Greenkeeper Bot 🌴

An in-range update of serverless is breaking the build 🚨

Version 1.30.1 of serverless was just published.

Branch Build failing 🚨
Dependency serverless
Current Version 1.30.0
Type devDependency

This version is covered by your current version range and after updating it in your project the build failed.

serverless is a devDependency of this project. It might not break your production code or affect downstream projects, but probably breaks your build or test tools, which may prevent deploying or publishing.

Status Details
  • continuous-integration/travis-ci/push: The Travis CI build could not complete due to an error (Details).

Release Notes 1.30.1 (16.08.2018)

Meta

Commits

The new version differs by 16 commits.

  • bee4e25 Merge pull request #5219 from serverless/platform-ci
  • 6cac76a releasing patch
  • 09e9b8d enable CI on platform deployment
  • 57a05e2 Merge pull request #5089 from gmadar/patch-1
  • 3972633 Merge pull request #5088 from kevinrambaud/update-aws-nodejs-template
  • db519eb Merge branch 'master' into update-aws-nodejs-template
  • f1d35ec Merge remote-tracking branch 'root/master'
  • a216110 Merge pull request #5208 from serverless/deterministic-resource-id
  • c4da743 Merge pull request #5207 from chackomathew/patch-1
  • 0b82770 Deterministic resourceId to fix state diffing on Platform
  • 41183c2 Update apigateway.md
  • e7d4b9d Merge pull request #5204 from serverless/alexdebrie-patch-1
  • 78af55d Update CHANGELOG.md
  • daedc59 Remove extra parenthesis
  • 596ec91 Update package.json

There are 16 commits in total.

See the full diff

FAQ and help

There is a collection of frequently asked questions. If those don’t help, you can always ask the humans behind Greenkeeper.


Your Greenkeeper Bot 🌴

An in-range update of serverless-dynamodb-local is breaking the build 🚨

The devDependency serverless-dynamodb-local was updated from 0.2.34 to 0.2.35.

🚨 View failing branch.

This version is covered by your current version range and after updating it in your project the build failed.

serverless-dynamodb-local is a devDependency of this project. It might not break your production code or affect downstream projects, but probably breaks your build or test tools, which may prevent deploying or publishing.

Status Details
  • continuous-integration/travis-ci/push: The Travis CI build could not complete due to an error (Details).

FAQ and help

There is a collection of frequently asked questions. If those don’t help, you can always ask the humans behind Greenkeeper.


Your Greenkeeper Bot 🌴

An in-range update of aws-sdk is breaking the build 🚨

Version 2.251.1 of aws-sdk was just published.

Branch Build failing 🚨
Dependency aws-sdk
Current Version 2.250.1
Type devDependency

This version is covered by your current version range and after updating it in your project the build failed.

aws-sdk is a devDependency of this project. It might not break your production code or affect downstream projects, but probably breaks your build or test tools, which may prevent deploying or publishing.

Status Details
  • continuous-integration/travis-ci/push The Travis CI build failed Details
  • coverage/coveralls First build on greenkeeper/aws-sdk-2.251.1 at 100.0% Details

Release Notes Release v2.251.1

See changelog for more information.

Commits

The new version differs by 1 commits.

See the full diff

FAQ and help

There is a collection of frequently asked questions. If those don’t help, you can always ask the humans behind Greenkeeper.


Your Greenkeeper Bot 🌴

An in-range update of aws-sdk is breaking the build 🚨

Version 2.253.1 of aws-sdk was just published.

Branch Build failing 🚨
Dependency aws-sdk
Current Version 2.252.1
Type devDependency

This version is covered by your current version range and after updating it in your project the build failed.

aws-sdk is a devDependency of this project. It might not break your production code or affect downstream projects, but probably breaks your build or test tools, which may prevent deploying or publishing.

Status Details
  • coverage/coveralls Coverage pending from Coveralls.io Details
  • continuous-integration/travis-ci/push The Travis CI build failed Details

Release Notes Release v2.253.1

See changelog for more information.

Commits

The new version differs by 1 commits.

See the full diff

FAQ and help

There is a collection of frequently asked questions. If those don’t help, you can always ask the humans behind Greenkeeper.


Your Greenkeeper Bot 🌴

Tracker

Articles

  • GET - Feed
  • GET - All articles
  • GET - Articles by author
  • GET - Articles favorited by username
  • GET - Articles by tag
  • POST - Create article
  • GET - Single article by slug
  • DEL - Delete article
  • PUT - Update article
  • POST - Favorite article
  • DEL - Unfavorite article

Auth

  • POST - Login
  • POST - Login and remember token
  • POST - Register
  • GET - Get current user
  • PUT - Update user

Comments

  • GET - All comments for article
  • POST - Create comment for article
  • DEL - Delete comment

Profile

  • GET - Profile
  • POST - Follow profile
  • DEL - Unfollow profile

Tags

  • GET - Get all tags

An in-range update of eslint is breaking the build 🚨

☝️ Greenkeeper’s updated Terms of Service will come into effect on April 6th, 2018.

Version 4.19.0 of eslint was just published.

Branch Build failing 🚨
Dependency eslint
Current Version 4.18.2
Type devDependency

This version is covered by your current version range and after updating it in your project the build failed.

eslint is a devDependency of this project. It might not break your production code or affect downstream projects, but probably breaks your build or test tools, which may prevent deploying or publishing.

Status Details
  • continuous-integration/travis-ci/push The Travis CI build failed Details

Release Notes v4.19.0
  • 55a1593 Update: consecutive option for one-var (fixes #4680) (#9994) (薛定谔的猫)
  • 8d3814e Fix: false positive about ES2018 RegExp enhancements (fixes #9893) (#10062) (Toru Nagashima)
  • 935f4e4 Docs: Clarify default ignoring of node_modules (#10092) (Matijs Brinkhuis)
  • 72ed3db Docs: Wrap Buffer() in backticks in no-buffer-constructor rule description (#10084) (Stephen Edgar)
  • 3aded2f Docs: Fix lodash typos, make spacing consistent (#10073) (Josh Smith)
  • e33bb64 Chore: enable no-param-reassign on ESLint codebase (#10065) (Teddy Katz)
  • 66a1e9a Docs: fix possible typo (#10060) (Vse Mozhet Byt)
  • 2e68be6 Update: give a node at least the indentation of its parent (fixes #9995) (#10054) (Teddy Katz)
  • 72ca5b3 Update: Correctly indent JSXText with trailing linebreaks (fixes #9878) (#10055) (Teddy Katz)
  • 2a4c838 Docs: Update ECMAScript versions in FAQ (#10047) (alberto)
Commits

The new version differs by 12 commits.

  • 4f595e8 4.19.0
  • 16fc59e Build: changelog update for 4.19.0
  • 55a1593 Update: consecutive option for one-var (fixes #4680) (#9994)
  • 8d3814e Fix: false positive about ES2018 RegExp enhancements (fixes #9893) (#10062)
  • 935f4e4 Docs: Clarify default ignoring of node_modules (#10092)
  • 72ed3db Docs: Wrap Buffer() in backticks in no-buffer-constructor rule description (#10084)
  • 3aded2f Docs: Fix lodash typos, make spacing consistent (#10073)
  • e33bb64 Chore: enable no-param-reassign on ESLint codebase (#10065)
  • 66a1e9a Docs: fix possible typo (#10060)
  • 2e68be6 Update: give a node at least the indentation of its parent (fixes #9995) (#10054)
  • 72ca5b3 Update: Correctly indent JSXText with trailing linebreaks (fixes #9878) (#10055)
  • 2a4c838 Docs: Update ECMAScript versions in FAQ (#10047)

See the full diff

FAQ and help

There is a collection of frequently asked questions. If those don’t help, you can always ask the humans behind Greenkeeper.


Your Greenkeeper Bot 🌴

An in-range update of aws-sdk is breaking the build 🚨

Version 2.268.1 of aws-sdk was just published.

Branch Build failing 🚨
Dependency aws-sdk
Current Version 2.267.1
Type devDependency

This version is covered by your current version range and after updating it in your project the build failed.

aws-sdk is a devDependency of this project. It might not break your production code or affect downstream projects, but probably breaks your build or test tools, which may prevent deploying or publishing.

Status Details
  • continuous-integration/travis-ci/push The Travis CI build could not complete due to an error Details

Release Notes Release v2.268.1

See changelog for more information.

Commits

The new version differs by 1 commits.

See the full diff

FAQ and help

There is a collection of frequently asked questions. If those don’t help, you can always ask the humans behind Greenkeeper.


Your Greenkeeper Bot 🌴

Scripts Output Seem to Jump Processees

Not necessarily a bug but a little strange for sure.

For example when I run npm test, the tests execute, then my terminal returns, but I get the following output showing under my fresh terminal.

$ ------------|----------|----------|----------|----------|-------------------|
File        |  % Stmts | % Branch |  % Funcs |  % Lines | Uncovered Line #s |
------------|----------|----------|----------|----------|-------------------|
All files   |      100 |      100 |      100 |      100 |                   |
 Article.js |      100 |      100 |      100 |      100 |                   |
 Comment.js |      100 |      100 |      100 |      100 |                   |
 User.js    |      100 |      100 |      100 |      100 |                   |
 Util.js    |      100 |      100 |      100 |      100 |                   |
------------|----------|----------|----------|----------|-------------------|
DynamoDB Local failed to start with code 143

This happened in iTerm in Mac OS and VSCode's embedded terminal.

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.