Skip to content

mikaelvesavuori/minimalist-serverless-starter

Repository files navigation

Opinionated minimalist realist serverless starter

Just a sample minimalist starter to run a modern AWS-deployed serverless TypeScript application with some quality-of-life tooling such as ESLint and Prettier. Packages and deploys using Serverless Framework and bundles it using esbuild.

Configurations

Configurations for ESLint and Prettier are reasonable starting points. The TypeScript config is very strict to get the most out of TS features. Serverless Framework is optimized (ARM architecture; short log retention; no versioning), CORS-activated, and set to safer-than-default settings.

Structure

The application separates AWS Lambda-specific handler stuff in src/handler.ts and business/application logic in src/index.ts. Tests for the business/application logic are in the tests folder and use AVA.

Prerequisites

  • Recent Node.js (ideally 18+) installed.
  • Amazon Web Services (AWS) account with sufficient permissions so that you can deploy infrastructure. A naive but simple policy would be full rights for CloudWatch, Lambda, API Gateway, and S3.
  • Ideally some experience with Serverless Framework as that's what we will use to deploy the service and infrastructure.

Installation

Clone, fork, or download the repo as you normally would. Run npm install.

Commands

  • npm start: Run application locally
  • npm test: Test the business/application logic with AVA
  • npm run build: Package application with Serverless Framework
  • npm run deploy: Deploy application to AWS with Serverless Framework
  • npm run teardown: Remove stack from AWS

Running locally

Using npm start you can start using the local endpoint http://localhost:3000/dev/greet to call the service.

curl http://localhost:3000/dev/greet -X POST -d '{ "name": "Zelda, Princess of Hyrule" }'

Which should respond back with:

"Hi Zelda, Princess of Hyrule!"

About

Opinionated minimalist realist serverless starter

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published