GithubHelp home page GithubHelp logo

serverless-localstack's Introduction

Project Pre-Requisite

There are some pre-requisite tools needed to run this project.


Project Setup

Follow these steps of command to get it up and running on your local computer.

1. Setup container and install dependencies

This command will setup localstack docker container and install node dependencies.

make -f sls-localstack-makefile docker-up
2. Deploy lambda function using Serverless

This command will install serverless globally using npm and deploy using Serverless.

make -f sls-localstack-makefile sls-deploy-local
3. Shut down container and remove Serverless resources

This command will shut down localstack container and remove deployed Serverless resources.

make -f sls-localstack-makefile docker-down

 


Project Testing

This section covers how you can test the deployed lambda from the previous steps.

1. Test deployed lambda locally using Postman

After running step 2 in project setup section you will be given a unique URL for the lambda deployed

Example lambda URL:

http://localhost:4566/restapis/d8nih0lkvm/local/_user_request_

Example payload:

{
    "eventType": "ORDER_CALLBACK",
    "data": {
        "name": "John Doe",
        "message": "Postman"
    }
}

Example response:

{
    "message": "Success sending message to SQS."
}
2. Test deployed lambda locally using Jest

This command will run test file in tests folder and test it against resource created using Serverless.

make -f sls-localstack-makefile sls-test-local

Example terminal output:

 PASS  tests/handler.test.js (20.053 s)
  ✓ should successfully send message to SQS (164 ms)
  ✓ should fail when event type is missing (1 ms)
  ✓ should fail when event type does not correspond to queue URL (1 ms)

Test Suites: 1 passed, 1 total
Tests:       3 passed, 3 total
Snapshots:   0 total
Time:        21.125 s, estimated 24 s
Ran all test suites.

serverless-localstack's People

Contributors

haziqfiqri avatar

Watchers

 avatar

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.