Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .bun-version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
1.3.10
8 changes: 4 additions & 4 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,15 +28,15 @@ jobs:

- uses: capralifecycle/actions-lib/check-runtime-dependencies@831b4c9c81e432ac57c25abbf8423abeebc8b40e # v1.6.5

- uses: actions/setup-node@6044e13b5dc448c55e2357c09f80417699197238 # v6.2.0
- uses: oven-sh/setup-bun@3d267786b128fe76c2f16a390aa2448b815359f3 # v2.1.2
with:
node-version-file: .node-version
bun-version-file: ".bun-version"

- name: build and test
run: make ci

- name: pack
run: npm pack --ignore-scripts
run: bun pm pack

- name: example project - build and test
working-directory: example
Expand All @@ -46,4 +46,4 @@ jobs:
if: ${{ github.ref == format('refs/heads/{0}', github.event.repository.default_branch) }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: npm run semantic-release
run: bun run semantic-release
4 changes: 2 additions & 2 deletions .github/workflows/update-snapshots.yml
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,9 @@ jobs:
ref: ${{ steps.pr.outputs.head_ref }}
fetch-depth: 0

- uses: actions/setup-node@6044e13b5dc448c55e2357c09f80417699197238 # v6.2.0
- uses: oven-sh/setup-bun@3d267786b128fe76c2f16a390aa2448b815359f3 # v2.1.2
with:
node-version-file: .node-version
bun-version-file: ".bun-version"

- name: Build and test
run: make build
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@ node_modules/
/lib/
/*.tgz
.idea
package-lock.json
1 change: 0 additions & 1 deletion .tool-versions

This file was deleted.

26 changes: 15 additions & 11 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,35 +2,39 @@
all: build

.PHONY: build
build: install fix test npm-build
build: install fix test bun-build

.PHONY: ci
ci: install check test npm-build
ci: install check test bun-build

.PHONY: install
install:
ifeq ($(CI),true)
npm ci
bun ci
else
npm install --ignore-scripts
bun install
endif

.PHONY: fix
fmt:
npm run fix
bun run fix

.PHONY: check
check:
npm run check
bun run check

.PHONY: npm-build
npm-build:
npm run build
.PHONY: clean
clean:
rm -rf dist lib

.PHONY: bun-build
bun-build:
bun run build

.PHONY: test
test:
npm run test -- --updateSnapshot
bun run test -- --updateSnapshot

.PHONY: upgrade-deps
upgrade-deps:
npm run upgrade-deps
bun run upgrade-deps
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ This is based on https://github.com/aws-samples/cloudfront-authorization-at-edge
## Usage

```bash
npm install @liflig/cdk-cloudfront-auth
bun add @liflig/cdk-cloudfront-auth
```

Deploy the Lambda@Edge functions to us-east-1:
Expand Down
45 changes: 45 additions & 0 deletions build.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
const entrypoints = [
"src/handlers/check-auth.ts",
"src/handlers/generate-secret.ts",
"src/handlers/http-headers.ts",
"src/handlers/parse-auth.ts",
"src/handlers/refresh-auth.ts",
"src/handlers/sign-out.ts",
]

const result = await Bun.build({
entrypoints,
outdir: "dist",
target: "node",
format: "cjs",
minify: true,
naming: {
entry: "[dir]/[name]/index.js",
},
loader: {
".html": "text",
},
})

if (!result.success) {
console.error("Build failed:")
for (const log of result.logs) {
console.error(log)
}
process.exit(1)
}

// Check bundle sizes (Lambda@Edge limit: 1MB for viewer request)
const MAX_SIZE = 1048576
for (const output of result.outputs) {
if (output.kind !== "entry-point") continue
const size = output.size
if (size > MAX_SIZE) {
console.error(
`Bundle too large: ${output.path} (${size} bytes, max ${MAX_SIZE})`,
)
process.exit(1)
}
}

console.log(`Built ${result.outputs.filter((o) => o.kind === "entry-point").length} bundles`)
1,702 changes: 1,702 additions & 0 deletions bun.lock

Large diffs are not rendered by default.

3 changes: 3 additions & 0 deletions bunfig.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[install]
minimumReleaseAge = 259200
minimumReleaseAgeExcludes = ["@liflig/cdk-lambda-config"]
9 changes: 3 additions & 6 deletions example/Makefile
Original file line number Diff line number Diff line change
@@ -1,14 +1,11 @@
.PHONY: all
all: ci

.PHONY: ci
ci: install test

.PHONY: install
install:
npm ci
npm install --no-save ../liflig-cdk-cloudfront-auth-0.0.0-development.tgz
bun ci
tar -xzf ../liflig-cdk-cloudfront-auth-0.0.0-development.tgz -C node_modules/@liflig/cdk-cloudfront-auth

.PHONY: test
test:
npm run test
bun run test
10 changes: 5 additions & 5 deletions example/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@ integration testing.

```bash
cd ..
npm pack
bun pm pack
cd example
npm install --no-save ../liflig-cdk-cloudfront-auth-0.0.0-development.tgz
bun install --no-save ../liflig-cdk-cloudfront-auth-0.0.0-development.tgz
# must be logged in to aws for next command
npx cdk deploy --all
bunx cdk deploy --all
```

See link to test page in outputs.
Expand All @@ -28,7 +28,7 @@ Add or remove user from `test` group to test authorization.
```bash
# (modify the next bucket name first, see deploy output)
aws s3 rm --recursive s3://cdk-cloudfront-auth-example-main-bucket83908e77-wc5jf6w82bqb
npx cdk destroy main
bunx cdk destroy main
# wait so that CloudFront frees up the lambdas
npx cdk destroy auth-lambdas
bunx cdk destroy auth-lambdas
```
124 changes: 124 additions & 0 deletions example/bun.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions example/bunfig.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[install]
minimumReleaseAge = 259200
minimumReleaseAgeExcludes = ["@liflig/cdk-cloudfront-auth"]
2 changes: 1 addition & 1 deletion example/cdk.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"app": "tsx bin/example.ts",
"app": "bun run bin/example.ts",
"requireApproval": "never",
"watch": {
"include": [
Expand Down
Loading