Skip to content

Commit 7b2f733

Browse files
authored
[DEV-3763] Removed cloudfront function build (#2130)
* removed cloudfront function build. Just go with js. There is no need to use type script * + changeset
1 parent 1c92d4f commit 7b2f733

File tree

12 files changed

+47
-201
lines changed

12 files changed

+47
-201
lines changed

.changeset/chubby-suits-build.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"infrastructure": minor
3+
---
4+
5+
Removed cloudfront function build. From now on we'll just go with java script

.github/workflows/code_review_infra.yaml

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -31,16 +31,7 @@ jobs:
3131
uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3.5.3
3232
with:
3333
submodules: recursive
34-
35-
- name: Setup Node.JS
36-
uses: ./.github/actions/setup-node
37-
38-
- name: Install dependencies
39-
run: npm ci --audit=false --fund=false
40-
41-
- name: Compile Cloudfront Functions
42-
run: npm run compile -w cloudfront-functions
43-
34+
4435
- name: Pull & update submodules recursively
4536
run: git submodule update --init --recursive
4637

.github/workflows/deploy_infra.yml

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ permissions:
3434
jobs:
3535
deploy:
3636
name: Terraform apply (manual on ${{ inputs.environment }})
37-
runs-on: ubuntu-latest
37+
runs-on: ubuntu-24.04
3838
continue-on-error: false
3939
environment: ${{ inputs.environment }}
4040

@@ -48,15 +48,6 @@ jobs:
4848
with:
4949
submodules: recursive
5050

51-
- name: Setup Node.JS
52-
uses: ./.github/actions/setup-node
53-
54-
- name: Install dependencies
55-
run: npm ci --audit=false --fund=false
56-
57-
- name: Compile Cloudfront Functions
58-
run: npm run compile -w cloudfront-functions
59-
6051
- name: Pull & update submodules recursively
6152
run: git submodule update --init --recursive
6253

apps/cloudfront-functions/.eslintrc.json

Lines changed: 0 additions & 6 deletions
This file was deleted.

apps/cloudfront-functions/CHANGELOG.md

Lines changed: 0 additions & 25 deletions
This file was deleted.

apps/cloudfront-functions/jest.config.js

Lines changed: 0 additions & 17 deletions
This file was deleted.

apps/cloudfront-functions/package.json

Lines changed: 0 additions & 24 deletions
This file was deleted.

apps/cloudfront-functions/src/__tests__/viewer-request-handler.test.ts

Lines changed: 0 additions & 50 deletions
This file was deleted.
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
"use strict";
2+
// This code is executed in the CloudFront Functions JavaScript runtime. In this
3+
// context we prefer performance over immutability.
4+
// https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/writing-function-code.html#function-code-modify-request
5+
/* eslint-disable functional/immutable-data */
6+
/* eslint-disable functional/no-expression-statements */
7+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
8+
var handler = function (event) {
9+
if (event.context.eventType === 'viewer-request') {
10+
// do the rewrite
11+
var request = event.request;
12+
var uri_1 = request.uri;
13+
// Check if the uri refers to a gitbook asset
14+
var isGitbookAssets = uri_1.startsWith('/gitbook/docs');
15+
var isWoff2 = uri_1.endsWith('.woff2'); // woff2 is a font format
16+
var uriEndsWithSlash = uri_1.endsWith('/');
17+
var isHomepage = uri_1 === '/';
18+
// List of special cases (add more as needed)
19+
var specialCases = ['.bollo', '.a', '.b', '.c'];
20+
// Function to check if URI ends with any of the special cases
21+
var isSpecialCase = specialCases.some(function (caseExt) { return uri_1.endsWith(caseExt); });
22+
if (!isHomepage) {
23+
if (uriEndsWithSlash) {
24+
request.uri = uri_1.replace(/\/$/, '');
25+
}
26+
// Always add .html if there's no file extension, including special cases
27+
if (!isGitbookAssets &&
28+
!isWoff2 &&
29+
(!/\.[a-zA-Z]+$/.test(uri_1) || isSpecialCase)) {
30+
request.uri += '.html';
31+
}
32+
}
33+
return request;
34+
}
35+
else {
36+
// do nothing
37+
return event.request;
38+
}
39+
};

apps/cloudfront-functions/src/viewer-request-handler.ts

Lines changed: 0 additions & 47 deletions
This file was deleted.

0 commit comments

Comments
 (0)