GitHub Repository
You can find the project source code on GitHub.
Prerequisites
- Install the Serverless Framework with
npm i serverless -g
Project Setup
Create a Serverless Framework application with the following options:package.json with @upstash/redis as a dependency:
package.json
Database Setup
Create a Redis database using Upstash Console or Upstash CLI and copy theUPSTASH_REDIS_REST_URL and UPSTASH_REDIS_REST_TOKEN into your .env file.
.env
Counter Function Setup
Updatehandler.js:
handler.js
serverless.yml to pass the environment variables:
serverless.yml