Giter Site home page Giter Site logo

anomalyinnovations / serverless-stack-demo-ext-api Goto Github PK

View Code? Open in Web Editor NEW
92.0 92.0 37.0 2.41 MB

Source for the extended version of the demo app API in Serverless Stack.

Home Page: https://serverless-stack.com

License: MIT License

JavaScript 100.00%

serverless-stack-demo-ext-api's People

Contributors

dependabot[bot] avatar fwang avatar jayair avatar seed-run-1 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

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

serverless-stack-demo-ext-api's Issues

How to debug services using vscode?

Installed serverless-offline
Trying to debug the services in vscode.
The debugger runs the lambda but doesn't pause on break points inside lambda code.
Any idea how to make it work?

Here's launch.json object:

    {
      "type": "node",
      "request": "launch",
      "name": "setupStreaming",
      "skipFiles": ["<node_internals>/**"],
      "program": "${workspaceRoot}/node_modules/.bin/sls",
      "cwd": "${workspaceFolder}/services/sessions",
      "stopOnEntry": true,
      "args": [
        "invoke",
        "local",
        "--function",
        "setupStreaming",
        "--stage",
        "dev",
        "--path",
        "./mocks/setupStreaming-event.mock.json"
      ]
    }

Serverless offline not working

Hi,
When i invoke the function locally with something like this, it works.
serverless invoke local -f get --path events/get-event.json

However when i try to do serverless offline it seems to screw up on the dynamoDB part and returns back a 500, { status: false}.

Also i deployed the resources and api as the guide suggested, and when i try hit the api gateway endpoint using postman i get the same 500, { status: false}. When i look on Xray to see whats wrong it says userId expected: S actual: NULL.

My guess is when i try postman the endpoint im not passing through the correct credentials. My header has a cognito-identity-id. In my authorisation i also have my aws access and secret key in it.

Can't seem to figure out the problem.

./startServer -> Error: Cannot find module 'http-proxy'

I've just done a fresh install with npm install and tried to launch the local server with the ./startServer but I got this error:

$ ./startServer 
internal/modules/cjs/loader.js:613
    throw err;
    ^

Error: Cannot find module 'http-proxy'
Require stack:
- C:\Users\stermi\dev\workspace_serverless\serverless-stack-demo-ext-api\startServer      
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:610:15)
    at Function.Module._load (internal/modules/cjs/loader.js:526:27)
    at Module.require (internal/modules/cjs/loader.js:666:19)
    at require (internal/modules/cjs/helpers.js:16:16)
    at Object.<anonymous> (C:\Users\stermi\dev\workspace_serverless\serverless-stack-demo-ext-api\startServer:5:19)
    at Module._compile (internal/modules/cjs/loader.js:759:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:770:10)
    at Module.load (internal/modules/cjs/loader.js:628:32)
    at Function.Module._load (internal/modules/cjs/loader.js:555:12)
    at Function.Module.runMain (internal/modules/cjs/loader.js:826:10)

how can I fix it?

update with TS support

hi everyone, it would be awesome if you could update the example to support the new serverless-bundle plugin that supports TS!

stack-demo-ext-api out of sync with stack-demo-api

I recently updated my api app to use the updated logic in the libs folder of the demo api but now I'm transitioning my app to the ext format to deploy on seed but the ext app hasn't been updated with the new logic.

Demo API Version

import AWS from "aws-sdk";
const client = new AWS.DynamoDB.DocumentClient();

export default {
  get   : (params) => client.get(params).promise(),
  put   : (params) => client.put(params).promise(),
  query : (params) => client.query(params).promise(),
  update: (params) => client.update(params).promise(),
  delete: (params) => client.delete(params).promise(),
};

EXT version

import AWS from "./aws-sdk";
import config from "../config";

const dynamoDb = new AWS.DynamoDB.DocumentClient();

export function call(action, params) {
  // Parameterize table names with stage name
  return dynamoDb[action]({
    ...params,
    TableName: `${config.resourcesStage}-${params.TableName}`
  }).promise();
}

Looks like we just need to spread the params into the table name stage.

get: (params) => client.get({
    ...params,
    TableName: `${config.resourcesStage}-${params.TableName}`
  }).promise()

FrontEnd Service

Hi,
this is more an idea or proposal than an issue.

I would be really great if there would be also one service with serverless.yml for frontend (for example react).

Cross-Referencing APIs not working with multiple Serverless files

Working with the tutorial here: https://serverless-stack.com/chapters/share-an-api-endpoint-between-services.html

However even after adding the following export:

resources:
  Outputs:
    ApiGatewayRestApiId:
      Value:
        Ref: ApiGatewayRestApi
      Export:
        Name: ${self:custom.stage}-ApiGatewayRestApiId

    ApiGatewayRestApiRootResourceId:
      Value:
        Fn::GetAtt:
          - ApiGatewayRestApi
          - RootResourceId
      Export:
        Name: ${self:custom.stage}-ApiGatewayRestApiRootResourceId

and the following import:

 apiGateway:
    restApiId:
      'Fn::ImportValue': ${self:custom.stage}-ApiGatewayRestApiId
    restApiRootResourceId:
      'Fn::ImportValue': ${self:custom.stage}-ApiGatewayRestApiRootResourceId

I still get the same error from all three APIs who are trying to reference the already existing API.

 Error: The CloudFormation template is invalid: Template format error: Unresolved resource dependencies [ApiGatewayRestApi] in the Resources block of the template
      at /tmp/seed/source/apis/saascharge/node_modules/serverless/lib/plugins/aws/deploy/lib/validateTemplate.js:20:13
      at tryCatcher (/tmp/seed/source/apis/saascharge/node_modules/bluebird/js/release/util.js:16:23)
      at Promise._settlePromiseFromHandler (/tmp/seed/source/apis/saascharge/node_modules/bluebird/js/release/promise.js:547:31)
      at Promise._settlePromise (/tmp/seed/source/apis/saascharge/node_modules/bluebird/js/release/promise.js:604:18)
      at Promise._settlePromise0 (/tmp/seed/source/apis/saascharge/node_modules/bluebird/js/release/promise.js:649:10)
      at Promise._settlePromises (/tmp/seed/source/apis/saascharge/node_modules/bluebird/js/release/promise.js:725:18)
      at _drainQueueStep (/tmp/seed/source/apis/saascharge/node_modules/bluebird/js/release/async.js:93:12)
      at _drainQueue (/tmp/seed/source/apis/saascharge/node_modules/bluebird/js/release/async.js:86:9)
      at Async._drainQueues (/tmp/seed/source/apis/saascharge/node_modules/bluebird/js/release/async.js:102:5)
      at Immediate.Async.drainQueues [as _onImmediate] (/tmp/seed/source/apis/saascharge/node_modules/bluebird/js/release/async.js:15:14)
      at processImmediate (internal/timers.js:456:21)
      at process.topLevelDomainCallback (domain.js:137:15)

Steps I have taken to debug:

  1. Verified that the export is being deployed prior to the import
    Screen Shot 2020-10-06 at 5 43 15 PM

  2. Verified that the syntax matches the tutorial above.

  3. Verified that the correct variables are being exported:
    Screen Shot 2020-10-06 at 5 46 15 PM

Is this tutorial just out of date? Any nudges in the right direction would be greatly appreciated.

No export named dev-ExtNotesTableArn found

Hi. Got this when running sls deploy from services/notes-api.

sls deploy
Serverless: Bundling with Webpack...
Serverless: Packaging service...
Serverless: Creating Stack...
Serverless: Checking Stack create progress...
.....
Serverless: Stack create finished...
Serverless: Uploading CloudFormation file to S3...
Serverless: Uploading artifacts...
Serverless: Uploading service create.zip file to S3 (761.74 KB)...
Serverless: Uploading service get.zip file to S3 (761.87 KB)...
Serverless: Uploading service list.zip file to S3 (761.88 KB)...
Serverless: Uploading service delete.zip file to S3 (761.7 KB)...
Serverless: Uploading service update.zip file to S3 (762.35 KB)...
Serverless: Validating template...
Serverless: Updating Stack...
Serverless: Checking Stack update progress...
..
Serverless: Operation failed!
Serverless: View the full error output: https://us-east-1.console.aws.amazon.com/cloudformation/home?region=us-east-1#/stack/detail?stackId=arn%3Aaws%3Acloudformation%3Aus-east-1%3A892036928957%3Astack%2Fnotes-app-ext-notes-api-dev%2Fa664cef0-21f5-11ea-94cc-0ef4281dfc4d

  Serverless Error ---------------------------------------

  An error occurred: notes-app-ext-notes-api-dev - No export named dev-ExtNotesTableArn found.

  Get Support --------------------------------------------
     Docs:          docs.serverless.com
     Bugs:          github.com/serverless/serverless/issues
     Issues:        forum.serverless.com

  Your Environment Information ---------------------------
     Operating System:          darwin
     Node Version:              10.16.0
     Serverless Version:        1.49.0
     Enterprise Plugin Version: 1.3.6
     Platform SDK Version:      2.1.0

Table names

The table names are still hard coded as ext-notes in the functions, shouldn't they be something like $serviceName-$stage-$functionName as mentioned in the guide?

Old dependancies? any reason?

  "devDependencies": {
    "aws-sdk": "^2.541.0",
    "serverless-bundle": "^1.2.5",
    "serverless-offline": "^5.12.0"
  },

Just wondering if there is any reason for this? As we are in 3.1.0 for serverless-bundle for example.

Assuming my understanding of the hats are correct

It will update you to the most recent major version (the first number). ^1.2.3 will match any 1.x.xrelease including 1.3.0, but will hold off on 2.0.0.

Cheers.

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.