GithubHelp home page GithubHelp logo

weisisheng / scheduled-hustlin-notifications Goto Github PK

View Code? Open in Web Editor NEW

This project forked from bdougie/scheduled-hustlin-notifications

0.0 1.0 0.0 10 KB

This is a lambda function that sends emails via postmark every morning

JavaScript 100.00%

scheduled-hustlin-notifications's Introduction

Hustlin is a project I created to let me know when there is a home baseball game happening. I get notifications every morning so I can plan my day around not using public transportation before, after, or during baseball games.

The code for the front-end react app can be found at bdougie/hustlin-react and mobile app at bdougie/HusslnMobile.

AWS Node Scheduled Emails

This is an example of creating a function that runs as a cron job using the serverless schedule event. It retrieves weather information at 10am (UTC) and emails it to a predefined recipient. For more information on schedule event check out the Serverless docs on schedule.

Cron syntax

cron(Minutes Hours Day-of-month Month Day-of-week Year)

All fields are required and time zone is UTC only.

Field Values Wildcards
Minutes 0-59 , - * /
Hours 0-23 , - * /
Day-of-month 1-31 , - * ? / L W
Month 1-12 or JAN-DEC , - * /
Day-of-week 1-7 or SUN-SAT , - * ? / L #
Year 1970-2199 , - * /

Read the AWS cron expression syntax docs for more info on how to setup cron

Setup

Postmark

Please visit https://postmarkapp.com to register for a free Postmark account.

Configuration

Upon setting up access to both external services, you'll be required to update the environment variables in serverless.yml:

environment:
  RECIPIENT: [email protected]
  POSTMARK_API_KEY: abc123
  POSTMARK_SENDER: [email protected]

Deploy

In order to deploy the you endpoint simply run

serverless deploy

The expected result should be similar to:

Serverless: Packaging service...
Serverless: Uploading CloudFormation file to S3...
Serverless: Uploading service .zip file to S3 (1.87 MB)...
Serverless: Updating Stack...
Serverless: Checking Stack update progress...
...........
Serverless: Stack update finished...
Serverless: Removing old service versions...
Service Information
service: scheduled-weather-example
stage: dev
region: us-east-1
api keys:
  None
endpoints:
  None
functions:
  email: arn:aws:lambda:us-east-1:219106525755:function:serverless-scheduled-hustlin

There is no additional step required. Your defined schedule becomes active right away after deployment.

Usage

To test your function remotely:

sls invoke -f email  

The expected result should be similar to:

{
  "success": true
}

scheduled-hustlin-notifications's People

Contributors

bdougie avatar

Watchers

James Cloos 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.