Skip to content

nthing2say/aws-node-http-api-typescript-project

Repository files navigation

Serverless Framework Node with Typescript HTTP API on AWS

This template demonstrates how to make a simple HTTP API with Node.js and Typescript running on AWS Lambda and API Gateway using the Serverless Framework v3.

This template does not include any kind of persistence (database). For more advanced examples, check out the serverless/examples repository which includes Typescript, Mongo, DynamoDB and other examples.

Setup

Run this command to initialize a new project in a new working directory. Ensure you have the Serverless Framework installed and you are using Node.js v20.

nvm install 20
nvm use 20
npm i

Usage

Deploy

serverless deploy -- verbose --aws-profile [aws-profile-name]

Invoke functions locally.

serverless invoke local --function hello
serverless invoke local --function starwars-films-get
serverless invoke local --function starwars-people-get
serverless invoke local --function task-post --data '{"body": "{\"title\":\"YourTitle\",\"description\":\"YourDescription\",\"done\":false}"}' --aws-profile [aws-profile-name]
serverless invoke local --function task-get --aws-profile [aws-profile-name]

Test locally

You can run the tests locally by running npm test .

npm test

Invoke functions remotely

[GET] https://r2yj9u8c1e.execute-api.us-east-1.amazonaws.com/
[GET] https://r2yj9u8c1e.execute-api.us-east-1.amazonaws.com/starwars-films
[GET] https://r2yj9u8c1e.execute-api.us-east-1.amazonaws.com/starwars-people
[POST] https://r2yj9u8c1e.execute-api.us-east-1.amazonaws.com/task --data '{"title":"YourTitle","description":"YourDescription","done":false}'
[GET] https://r2yj9u8c1e.execute-api.us-east-1.amazonaws.com/task

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published