overhaul readme to match the project

This commit is contained in:
Travis Shears 2024-06-25 10:35:50 +02:00
parent ef8144ba26
commit f283893064

View file

@ -1,56 +1,38 @@
<!-- # Micro Blog Repo Fetchers
title: 'AWS Node Scheduled Cron example in NodeJS'
description: 'This is an example of creating a function that runs as a cron job using the serverless ''schedule'' event.'
layout: Doc
framework: v4
platform: AWS
language: nodeJS
priority: 1
authorLink: 'https://github.com/0dj0bz'
authorName: 'Rob Abbott'
authorAvatar: 'https://avatars3.githubusercontent.com/u/5679763?v=4&s=140'
-->
# Serverless Framework Node Scheduled Cron on AWS The Micro Blog Repo is made up of a PocketBase db and these lambda functions. Together they aggregate, backup, and make my various social media posts available to my personal site.
This template demonstrates how to develop and deploy a simple cron-like service running on AWS Lambda using the Serverless Framework. ## Progress
This examples defines a single function, `rateHandler` which is triggered by an event of `schedule` type at a rate of 1 per minute. For detailed information about `schedule` event, please refer to corresponding section of Serverless [docs](https://serverless.com/framework/docs/providers/aws/events/schedule/). - [X] [BlueSky](https://bsky.app/profile/travisshears.bsky.social)
- [ ] Old Pleroma formally social.travisshears.xyz
- [ ] Video support
- [X] Post support
- [X] Post with image support
- [X] [Pixelfed via gram.social](https://gram.social/i/web/profile/703621281309160235)
- [ ] [Mastodon via dice.camp](https://dice.camp/@travisshears)
- [ ] [Nostr profile1qqs9....](https://snort.social/nprofile1qqs9udcv9uhqggjz87js9rtaph4lajlxnxsvwvm7zwdjt6etzyk52rgpypmhxue69uhkummnw3ezuetfde6kuer6wasku7nfvuh8xurpvdjj7qgkwaehxw309ajkgetw9ehx7um5wghxcctwvshszrnhwden5te0dehhxtnvdakz7z94haj)
## Usage
### Deployment ## Deployment
In order to deploy the example, you need to run the following command: To deploy all the lambda functions to AWS:
``` ```shell
serverless deploy $ yarn deploy
``` ```
After running deploy, you should see output similar to: After the deploy to manually trigger a fn run:
```
Deploying "aws-node-scheduled-cron" to stage "dev" (us-east-1)
✔ Service deployed to stack aws-node-scheduled-cron-dev (151s)
functions:
rateHandler: aws-node-scheduled-cron-dev-rateHandler (2.3 kB)
```shell
$ yarn exec serverless invoke --function bluesky
``` ```
There is no additional step required. Your defined schedules becomes active right away after deployment. ## Local development
### Local development
The easiest way to develop and test your function is to use the `dev` command: ```shell
$ yarn exec serverless invoke local --function bluesky
```
serverless dev
``` ```
This will start a local emulator of AWS Lambda and tunnel your requests to and from AWS Lambda, allowing you to interact with your function as if it were running in the cloud. There is also the new `serverless dev` command. I still need to check that out.
Now you can invoke the function as before, but this time the function will be executed locally. Now you can develop your function locally, invoke it, and see the results immediately without having to re-deploy.
When you are done developing, don't forget to run `serverless deploy` to deploy the function to the cloud.