Coder Social home page Coder Social logo

push-notification-lambda's Introduction

push-notification-lambda

This is a Serverless application that utilises Lambda, API Gateway and DynamoDB.

  • events - Invocation events that you can use to invoke the function.
  • tests - Unit tests for the application code.
  • service - the functions.
  • serverless.yml - A template that defines the application's AWS resources.

Setup

You will require an Apple Developer push certificate in the form of a .p8 file. These can be obtained from the developer console.

Ideally, your private keys should be stored in Secrets Manager, and an example of this implementation has also been provided.

If you don't already have Serverless, install it globally:

npm install -g serverless

Create an .env.local file for env vars and values:

APPLE_PN_KEY_ID

APPLE_TEAM_ID

KEY_PATH

JWT_SECRET

Generate a random base64 string for the JWT_SECRET:

openssl rand -base64 32

Run

push-notification-lambda$ npm install
push-notification-lambda$ npm start

Setup your postman to send POST requests to:

http://localhost:3000/dev/notification

http://localhost:3000/dev/onboard

https://{apigatewayid}.execute-api.ap-southeast-2.amazonaws.com/dev/notification

https://{apigatewayid}.execute-api.ap-southeast-2.amazonaws.com/dev/onboard

Note that the body format changes for invoking the functions through API Gateway.

Each function's route is defined in serverless.yml:

      Events:
        PushNotification:
          Type: Api
          Properties:
            Path: /notification
            Method: post

Unit tests

Tests are defined in the tests folder in this project. Use NPM to install the Mocha test framework and run unit tests from your local machine.

push-notification-lambda$ npm run test

Deploy

push-notification-lambda$ npm run deploy

push-notification-lambda's People

Contributors

elarcoiris avatar dependabot[bot] 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.