Loading repository data…
Loading repository data…
jorshali / repository
TypeScript-based starter REST API project using AWS SAM that provides Cognito authentication, custom authorization, and a REST handling framework.
A transparent discovery signal based on current public GitHub metadata.
This score does not audit code, security, maintainers, documentation quality, or suitability. Verify the repository and its current documentation before adoption.
A TypeScript-based starter project for creating a REST API with AWS SAM. For a complete tutorial using this project, check out: Build a REST API with TypeScript in 5 Minutes.
The project generates a REST API that uses the following AWS services:
By simply following the setup instructinos, you can have a secured, TypeScript-based REST API deployed to AWS in minutes.
The following prerequesites are needed:
Once you have installed the necessary prerequisites you can setup the project with the following command:
$ mkdir <project-directory>
$ cd <project-directory>
$ sam init --location git@github.com:jorshali/aws-sam-rest-api-starter.git
The starter project will now be available in the project directory you created.
The following prerequesites are needed:
Once you have completed the prerequesites, follow these steps to deploy to an AWS environment:
$ export AWS_PROFILE=<my-deployment-profile>
sam build --beta-features
sam deploy --guided
While being guided through the deployment, the defaults are recommended except for the Stack Name. You can customize the Stack Name to something specific to your project.
Service endpoint URL for your App configuration
https://{ApiGatewayApi}.execute-api.{AWS::Region}.amazonaws.com/V1/
The ID of the UserPool for use when running the environment setup script
<user-pool-id>
The AWS ClientId that should be used in your authentication configuration
<user-pool-add-client-id>
Hang onto these values as you will need them for the data setup and your calling application.
There are several included scripts for setting up the environment with default data for initial testing. These commands will ask for some information provided by the project build.
Simply run the following command:
$ sh scripts/setup.sh
Once the data has been setup, you likely want to add a user. This can be done with the following command:
$ sh scripts/add-user.sh
If you have Docker installed, you can start the project locally with the following commands:
$ sam build
$ sam local start-api
Now that you have the project running, you probably want to do something useful. The default project creates a CRUD service for blog posts. This service implements:
These service calls retrieve the data found in the DynamoDB table POST. To customize this service, have a look at the blogposts\index.ts file.