blob: 1196082a02feecfe93b4785fe5cf3548ff5976bf (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
|
# cs5260 consumer
This project uses the [Bun TS Runtime](https://bun.sh/)
To install dependencies:
```bash
bun install
```
To run:
```bash
bun run index.ts
```
With the arguments:
```
--sourcebucket: the bucket to poll for widget requests
--storagebucket: the bucket to store and modify widgets according to received requests
--storagetable: the DDB table to store and modify widgets according to received requests
--storageprefix: the prefix to store S3 objects in (only required if storagebucket is given)
```
And either one of storagebucket or storagetable must be given.
Unit tests:
```bash
bun test
```
## Lambda Handler
There is a current bug in bun 1.0.8, the latest version: [https://github.com/oven-sh/bun/issues/7028],
which is not present in v1.0.7 and earlier. Thus, I recommend using `asdf` to manage the bun version in
this part of the project.
To deploy the lambda handler, first build and publish the Bun runtime layer on your
AWS account:
```bash
bun run build-layer --arch aarch64 \
--release 1.0.7 --output ./bun-lambda-layer.zip
bun run publish-layer --region us-east-1 \
--arch aarch64 --release 1.0.7 \
--output ./bun-lambda-layer.zip
```
Then, create a Lambda function with runtime "custom bootstrap on amazon linux 2" and
name "widget-api-handler", and handler to "handler.fetch" (found in "Code").
In the Lambda console then attach the layer "bun".
|