Skip to main content
Brave Programmer Logo

BraveProgrammer

BraveProgrammer

HomeProjectsBlogsCoursesLessonsAbout

Site footer

BraveProgrammer

Free coding courses, practical tutorials, and real projects from BraveProgrammer. Learn web development with React, Next.js, and TypeScript.

Navigation

  • Home
  • Projects
  • Blogs
  • Courses

Resources

  • About
  • Lessons
  • Teach on BraveProgrammer

© 2026 BraveProgrammer. All rights reserved.

Serverless Functions – AWS Lambd | TypeScript Mastery lesson | BraveProgrammer
  1. Courses
  2. /
  3. TypeScript Mastery

Lesson 51 of 56

·Typescript

Serverless Functions – AWS Lambda with TypeScript

25 minutes

Course progress91%

Set up a Lambda project

npm init -y
npm i -D typescript @types/aws-lambda @aws-sdk/client-s3
npm i aws-lambda
npx tsc --init

Handler example

import { APIGatewayProxyEvent, APIGatewayProxyResult } from 'aws-lambda';

export  handler =  (: ): <> => {
   name = event.?. ?? ;
   {
    : ,
    : { :  },
    : .({ :  })
  };
};
const
async
event
APIGatewayProxyEvent
Promise
APIGatewayProxyResult
const
queryStringParameters
name
'world'
return
statusCode
200
headers
'Content-Type'
'application/json'
body
JSON
stringify
message
`Hello, ${name}!`

Build & package

npm run build   # tsc → ./dist
zip -r function.zip dist/*

Upload function.zip via AWS Console or use the Serverless Framework:

npm i -g serverless
sls create -t aws-nodejs-typescript -p my-service

Testing locally with sam

sam local invoke "HelloFunction" -e event.json

Info

Remember to set runtime: nodejs20.x in serverless.yml and enable source maps for better debugging.
Make it stickPractice what you've learned1 quiz · 3 practical tests · Optional activities from TypeScript MasteryBrowse activities
Previous lessonDeno – Secure Runtime for TypeScriptContinue to lesson 52GraphQL with TypeScript – `type-graphql`Back to TypeScript Mastery curriculum