This project consists of a couple of APIs that help demonstrate the functionality in [Apicize][https://github.com/apicize/apicize]. They are implemented using AWS Lambda and API Gateway and are deployed using the AWS Serverless Application Model
Accepts an image file posted as Base64 and rotates it. Image size is limited by Lambda's invocation payload of 6 MB. Requires bearer token issued by /token
.
CRUD services to store quote information in a DynamoDb database. Requires bearer token issued by /token
, and entries are tied to the token used to submit them.
A minimial OAuth2-ish that issues tokens which expire in 10 minutes. (note: this is not a "real" authentication/authorization service)
If you are going to deploy this for yourself, refer to the SAM template for parameters to configure.
To run locally, you can create an env.local.json
with the following contents
{
"IssueTokenFunction": {
"TABLE_NAME_TOKENS": "my-token-table",
"CIPHER_KEY": "xxxxxxxxxxxx"
},
"ImageFunction": {
"TABLE_NAME_TOKENS": "my-token-table",
"CIPHER_KEY": "xxxxxxxxxxxx"
},
"QuotesFunction": {
"TABLE_NAME_TOKENS": "my-token-table",
"TABLE_NAME_QUOTES": "my-quote-table",
"CIPHER_KEY": "xxxxxxxxxxxx"
}
}
You can generate a cipher key using the following NodeJS code:
Buffer.from(await crypto.subtle.exportKey('raw', await crypto.subtle.generateKey({name: 'AES-CBC', length: 256},true,['encrypt','decrypt']))).toString('base64')
NPM scripts are included to assist with running locally and deploying:
- build: builds all Lambda functions using esbuild
- start: launches services locally using AWS SAM
- debug: launches services locally using AWS SAM with debug enabled
- deploy: deploys services to Lambda (you will probaby want to run
sam deploy --guided
the firsd time to generate asamconfig.toml
file)