https://github.com/willis0826/serverless-local-authorizer-example
A demo for Serverless Framework with Lambda Authorizer
https://github.com/willis0826/serverless-local-authorizer-example
api-gateway authorizer lambda serverless-framework
Last synced: 11 months ago
JSON representation
A demo for Serverless Framework with Lambda Authorizer
- Host: GitHub
- URL: https://github.com/willis0826/serverless-local-authorizer-example
- Owner: Willis0826
- Created: 2024-02-10T22:22:50.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2024-02-11T01:33:46.000Z (over 2 years ago)
- Last Synced: 2025-02-28T10:09:05.074Z (over 1 year ago)
- Topics: api-gateway, authorizer, lambda, serverless-framework
- Language: TypeScript
- Homepage: https://www.willischou.com/aws-serverless-using-serverless-framework-with-custom-authoriser-locally/
- Size: 76.2 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# serverless local authorizer example
This project demos how to use Serverless Framework with Lambda Authorizer locally for REST APIs (API Gateway V1).
Check out the article that walks you through this repository.
[AWS Serverless - Using Serverless Framework with Custom Authoriser Locally](https://www.willischou.com/aws-serverless-using-serverless-framework-with-custom-authoriser-locally/)
## Requirement
1. Nodejs 20
Run the following command to install packages.
```bash
$ npm i
```
## Start Dev Server
Wicked, you can start serverless dev server locally and test the result.
```bash
$ npm run start
$ curl -H "Authorization: abc" http://localhost:3000/dev/ping
```
Now, you should get a response `pong` after you sent a GET request to `/ping`. Please note, you must provide `Authorization` header in the request in order to pass Lambda Authorizer.
If you send a request without `Authorization` header, you will get a response `{"message":"Unauthorized"}`.
🍺 Cheers, that's all. You can enjoy the seamless Lambda development with TypeScript locally.