Skip to content

Commit 1ed991a

Browse files
author
Tarash Agarwal
committed
Merge branch 'main' of github.com:acm-uiuc/core into siglead-management
2 parents 9c5627a + 697d310 commit 1ed991a

File tree

93 files changed

+6991
-1123
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

93 files changed

+6991
-1123
lines changed

.devcontainer/devcontainer.json

Lines changed: 29 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,41 +1,39 @@
11
// For format details, see https://aka.ms/devcontainer.json. For config options, see the
22
// README at: https://github.com/devcontainers/templates/tree/main/src/ubuntu
33
{
4-
"name": "Ubuntu",
5-
// Or use a Dockerfile or Docker Compose file. More info: https://containers.dev/guide/dockerfile
6-
"image": "mcr.microsoft.com/devcontainers/base:jammy",
7-
"features": {
8-
"ghcr.io/devcontainers/features/node:1": {},
4+
"name": "Ubuntu",
5+
// Or use a Dockerfile or Docker Compose file. More info: https://containers.dev/guide/dockerfile
6+
"image": "mcr.microsoft.com/devcontainers/base:jammy",
7+
"features": {
8+
"ghcr.io/devcontainers/features/node:1": {},
99
"ghcr.io/devcontainers/features/aws-cli:1": {},
10-
"ghcr.io/jungaretti/features/make:1": {},
11-
"ghcr.io/customink/codespaces-features/sam-cli:1": {},
12-
"ghcr.io/devcontainers/features/python:1": {}
13-
},
10+
"ghcr.io/jungaretti/features/make:1": {},
11+
"ghcr.io/customink/codespaces-features/sam-cli:1": {},
12+
"ghcr.io/devcontainers/features/python:1": {},
13+
"ghcr.io/devcontainers/features/docker-outside-of-docker:1": {}
14+
},
1415

15-
// Features to add to the dev container. More info: https://containers.dev/features.
16-
// "features": {},
16+
// Features to add to the dev container. More info: https://containers.dev/features.
17+
// "features": {},
1718

18-
// Use 'forwardPorts' to make a list of ports inside the container available locally.
19-
"forwardPorts": [
20-
8080,
21-
5173
22-
],
23-
"customizations": {
24-
"vscode": {
25-
"extensions": [
26-
"EditorConfig.EditorConfig",
27-
"waderyan.gitblame",
28-
"Gruntfuggly.todo-tree"
29-
]
30-
}
31-
}
19+
// Use 'forwardPorts' to make a list of ports inside the container available locally.
20+
"forwardPorts": [8080, 5173],
21+
"customizations": {
22+
"vscode": {
23+
"extensions": [
24+
"EditorConfig.EditorConfig",
25+
"waderyan.gitblame",
26+
"Gruntfuggly.todo-tree"
27+
]
28+
}
29+
}
3230

33-
// Use 'postCreateCommand' to run commands after the container is created.
34-
// "postCreateCommand": "uname -a",
31+
// Use 'postCreateCommand' to run commands after the container is created.
32+
// "postCreateCommand": "uname -a",
3533

36-
// Configure tool-specific properties.
37-
// "customizations": {},
34+
// Configure tool-specific properties.
35+
// "customizations": {},
3836

39-
// Uncomment to connect as root instead. More info: https://aka.ms/dev-containers-non-root.
40-
// "remoteUser": "root"
37+
// Uncomment to connect as root instead. More info: https://aka.ms/dev-containers-non-root.
38+
// "remoteUser": "root"
4139
}

.github/workflows/deploy-dev.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ jobs:
8181
- uses: aws-actions/configure-aws-credentials@v4
8282
with:
8383
role-to-assume: arn:aws:iam::427040638965:role/GitHubActionsRole
84-
role-session-name: Core_Dev_Deployment
84+
role-session-name: Core_Dev_Deployment_${{ github.run_id }}
8585
aws-region: us-east-1
8686

8787
- name: Publish to AWS

.github/workflows/deploy-prod.yml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ jobs:
4242
uses: actions/setup-node@v4
4343
with:
4444
node-version: 22.x
45+
4546
- uses: actions/checkout@v4
4647
env:
4748
HUSKY: "0"
@@ -55,7 +56,7 @@ jobs:
5556
- uses: aws-actions/configure-aws-credentials@v4
5657
with:
5758
role-to-assume: arn:aws:iam::427040638965:role/GitHubActionsRole
58-
role-session-name: Core_Dev_Prod_Deployment
59+
role-session-name: Core_Dev_Prod_Deployment_${{ github.run_id }}
5960
aws-region: us-east-1
6061
- name: Publish to AWS
6162
run: make deploy_dev
@@ -90,6 +91,7 @@ jobs:
9091
uses: actions/setup-node@v4
9192
with:
9293
node-version: 22.x
94+
9395
- uses: actions/checkout@v4
9496
env:
9597
HUSKY: "0"
@@ -103,7 +105,7 @@ jobs:
103105
- uses: aws-actions/configure-aws-credentials@v4
104106
with:
105107
role-to-assume: arn:aws:iam::298118738376:role/GitHubActionsRole
106-
role-session-name: Core_Dev_Prod_Deployment
108+
role-session-name: Core_Dev_Prod_Deployment_${{ github.run_id }}
107109
aws-region: us-east-1
108110
- name: Publish to AWS
109111
run: make deploy_prod

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,3 +142,4 @@ __pycache__
142142
/blob-report/
143143
/playwright/.cache/
144144
dist_devel/
145+
!src/ui/pages/logs

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ build: src/ cloudformation/ docs/
5858
VITE_BUILD_HASH=$(GIT_HASH) yarn build
5959
cp -r src/api/resources/ dist/api/resources
6060
rm -rf dist/lambda/sqs
61-
sam build --template-file cloudformation/main.yml
61+
sam build --template-file cloudformation/main.yml --use-container
6262
mkdir -p .aws-sam/build/AppApiLambdaFunction/node_modules/aws-crt/
6363
cp -r node_modules/aws-crt/dist .aws-sam/build/AppApiLambdaFunction/node_modules/aws-crt
6464

cloudformation/iam.yml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@ Resources:
7777
- Fn::Sub: arn:aws:dynamodb:${AWS::Region}:${AWS::AccountId}:table/infra-core-api-room-requests
7878
- Fn::Sub: arn:aws:dynamodb:${AWS::Region}:${AWS::AccountId}:table/infra-core-api-room-requests-status
7979
- Fn::Sub: arn:aws:dynamodb:${AWS::Region}:${AWS::AccountId}:table/infra-core-api-linkry
80+
- Fn::Sub: arn:aws:dynamodb:${AWS::Region}:${AWS::AccountId}:table/infra-core-api-keys
8081
# Index accesses
8182
- Fn::Sub: arn:aws:dynamodb:${AWS::Region}:${AWS::AccountId}:table/infra-core-api-stripe-links/index/*
8283
- Fn::Sub: arn:aws:dynamodb:${AWS::Region}:${AWS::AccountId}:table/infra-core-api-events/index/*
@@ -106,6 +107,16 @@ Resources:
106107
Resource:
107108
- Fn::Sub: arn:aws:dynamodb:${AWS::Region}:${AWS::AccountId}:table/infra-core-api-rate-limiter
108109

110+
- Sid: DynamoDBAuditLogTableAccess
111+
Effect: Allow
112+
Action:
113+
- dynamodb:DescribeTable
114+
- dynamodb:PutItem
115+
- dynamodb:Query
116+
Resource:
117+
- Fn::Sub: arn:aws:dynamodb:${AWS::Region}:${AWS::AccountId}:table/infra-core-api-audit-log
118+
- Fn::Sub: arn:aws:dynamodb:${AWS::Region}:${AWS::AccountId}:table/infra-core-api-audit-log/index/*
119+
109120
- Sid: DynamoDBStreamAccess
110121
Effect: Allow
111122
Action:

cloudformation/logs.yml

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,3 +21,26 @@ Resources:
2121
LogGroupName:
2222
Fn::Sub: /aws/lambda/${LambdaFunctionName}-edge
2323
RetentionInDays: 7
24+
AppAuditLog:
25+
Type: "AWS::DynamoDB::Table"
26+
DeletionPolicy: "Retain"
27+
UpdateReplacePolicy: "Retain"
28+
Properties:
29+
BillingMode: "PAY_PER_REQUEST"
30+
TableName: infra-core-api-audit-log
31+
DeletionProtectionEnabled: true
32+
PointInTimeRecoverySpecification:
33+
PointInTimeRecoveryEnabled: true
34+
AttributeDefinitions:
35+
- AttributeName: module
36+
AttributeType: S
37+
- AttributeName: createdAt
38+
AttributeType: N
39+
KeySchema:
40+
- AttributeName: module
41+
KeyType: HASH
42+
- AttributeName: createdAt
43+
KeyType: RANGE
44+
TimeToLiveSpecification:
45+
AttributeName: expiresAt
46+
Enabled: true

cloudformation/main.yml

Lines changed: 65 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ Mappings:
4848
LogRetentionDays: 7
4949
SesDomain: "aws.qa.acmuiuc.org"
5050
prod:
51-
LogRetentionDays: 365
51+
LogRetentionDays: 90
5252
SesDomain: "acm.illinois.edu"
5353
ApiGwConfig:
5454
dev:
@@ -151,7 +151,7 @@ Resources:
151151
DependsOn:
152152
- AppLogGroups
153153
Properties:
154-
Architectures: [arm64]
154+
Architectures: [x86_64]
155155
CodeUri: ../dist/lambda
156156
AutoPublishAlias: live
157157
Runtime: nodejs22.x
@@ -166,7 +166,7 @@ Resources:
166166
RunEnvironment: !Ref RunEnvironment
167167
EntraRoleArn: !GetAtt AppSecurityRoles.Outputs.EntraFunctionRoleArn
168168
LinkryKvArn: !GetAtt LinkryRecordsCloudfrontStore.Arn
169-
AWS_CRT_NODEJS_BINARY_RELATIVE_PATH: node_modules/aws-crt/dist/bin/linux-arm64-glibc/aws-crt-nodejs.node
169+
AWS_CRT_NODEJS_BINARY_RELATIVE_PATH: node_modules/aws-crt/dist/bin/linux-x64-glibc/aws-crt-nodejs.node
170170
VpcConfig:
171171
Ipv6AllowedForDualStack: !If [ShouldAttachVpc, True, !Ref AWS::NoValue]
172172
SecurityGroupIds:
@@ -198,7 +198,7 @@ Resources:
198198
DependsOn:
199199
- AppLogGroups
200200
Properties:
201-
Architectures: [arm64]
201+
Architectures: [x86_64]
202202
CodeUri: ../dist/sqsConsumer
203203
AutoPublishAlias: live
204204
Runtime: nodejs22.x
@@ -273,6 +273,26 @@ Resources:
273273
- AttributeName: email
274274
KeyType: HASH
275275

276+
ApiKeyTable:
277+
Type: "AWS::DynamoDB::Table"
278+
DeletionPolicy: "Retain"
279+
UpdateReplacePolicy: "Retain"
280+
Properties:
281+
BillingMode: "PAY_PER_REQUEST"
282+
TableName: infra-core-api-keys
283+
DeletionProtectionEnabled: !If [IsProd, true, false]
284+
PointInTimeRecoverySpecification:
285+
PointInTimeRecoveryEnabled: !If [IsProd, true, false]
286+
AttributeDefinitions:
287+
- AttributeName: keyId
288+
AttributeType: S
289+
KeySchema:
290+
- AttributeName: keyId
291+
KeyType: HASH
292+
TimeToLiveSpecification:
293+
AttributeName: expiresAt
294+
Enabled: true
295+
276296
ExternalMembershipRecordsTable:
277297
Type: "AWS::DynamoDB::Table"
278298
DeletionPolicy: "Retain"
@@ -736,6 +756,38 @@ Resources:
736756
- HEAD
737757
CachePolicyId: !Ref CloudfrontCachePolicy
738758
OriginRequestPolicyId: 216adef6-5c7f-47e4-b989-5492eafa07d3
759+
- PathPattern: "/api/v1/organizations"
760+
TargetOriginId: ApiGatewayOrigin
761+
ViewerProtocolPolicy: redirect-to-https
762+
AllowedMethods:
763+
- GET
764+
- HEAD
765+
- OPTIONS
766+
- PUT
767+
- POST
768+
- DELETE
769+
- PATCH
770+
CachedMethods:
771+
- GET
772+
- HEAD
773+
CachePolicyId: "658327ea-f89d-4fab-a63d-7e88639e58f6"
774+
OriginRequestPolicyId: 216adef6-5c7f-47e4-b989-5492eafa07d3
775+
- PathPattern: "/api/documentation*"
776+
TargetOriginId: ApiGatewayOrigin
777+
ViewerProtocolPolicy: redirect-to-https
778+
AllowedMethods:
779+
- GET
780+
- HEAD
781+
- OPTIONS
782+
- PUT
783+
- POST
784+
- DELETE
785+
- PATCH
786+
CachedMethods:
787+
- GET
788+
- HEAD
789+
CachePolicyId: "658327ea-f89d-4fab-a63d-7e88639e58f6"
790+
OriginRequestPolicyId: 216adef6-5c7f-47e4-b989-5492eafa07d3
739791
- PathPattern: "/api/*"
740792
TargetOriginId: ApiGatewayOrigin
741793
ViewerProtocolPolicy: redirect-to-https
@@ -901,6 +953,15 @@ Resources:
901953
async function handler(event) {
902954
const request = event.request;
903955
const path = request.uri.replace(/^\/+/, '');
956+
if (path === "") {
957+
return {
958+
statusCode: 301,
959+
statusDescription: 'Found',
960+
headers: {
961+
'location': { value: "https://core.acm.illinois.edu/linkry" }
962+
}
963+
}
964+
}
904965
let redirectUrl = "https://acm.illinois.edu/404";
905966
try {
906967
const value = await kvs.get(path);

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
"lint": "yarn workspaces run lint",
1818
"prepare": "node .husky/install.mjs || true",
1919
"typecheck": "yarn workspaces run typecheck",
20-
"test:unit": "cross-env RunEnvironment='dev' vitest run --coverage tests/unit --config tests/unit/vitest.config.ts && yarn workspace infra-core-ui run test:unit",
20+
"test:unit": "cross-env RunEnvironment='dev' vitest run --coverage --config tests/unit/vitest.config.ts tests/unit && yarn workspace infra-core-ui run test:unit",
2121
"test:unit-ui": "yarn test:unit --ui",
2222
"test:unit-watch": "vitest tests/unit",
2323
"test:live": "vitest tests/live",
@@ -44,6 +44,7 @@
4444
"concurrently": "^9.1.2",
4545
"cross-env": "^7.0.3",
4646
"esbuild": "^0.23.0",
47+
"esbuild-plugin-copy": "^2.1.1",
4748
"eslint": "^8.57.0",
4849
"eslint-config-airbnb": "^19.0.4",
4950
"eslint-config-airbnb-typescript": "^18.0.0",

src/api/build.js

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import esbuild from "esbuild";
22
import { resolve } from "path";
3+
import { copy } from 'esbuild-plugin-copy'
34

45

56
const commonParams = {
@@ -15,7 +16,7 @@ const commonParams = {
1516
target: "es2022", // Target ES2022
1617
sourcemap: false,
1718
platform: "node",
18-
external: ["aws-sdk", "moment-timezone", "passkit-generator", "fastify"],
19+
external: ["aws-sdk", "moment-timezone", "passkit-generator", "fastify", "zod", "zod-openapi", "@fastify/swagger", "@fastify/swagger-ui", "argon2"],
1920
alias: {
2021
'moment-timezone': resolve(process.cwd(), '../../node_modules/moment-timezone/builds/moment-timezone-with-data-10-year-range.js')
2122
},
@@ -27,8 +28,26 @@ const commonParams = {
2728
const require = topLevelCreateRequire(import.meta.url);
2829
const __filename = fileURLToPath(import.meta.url);
2930
const __dirname = path.dirname(__filename);
31+
import "zod-openapi/extend";
3032
`.trim(),
3133
}, // Banner for compatibility with CommonJS
34+
plugins: [
35+
copy({
36+
resolveFrom: 'cwd',
37+
assets: {
38+
from: ['../../node_modules/@fastify/swagger-ui/static/*'],
39+
to: ['../../dist/lambda/static'],
40+
},
41+
}),
42+
copy({
43+
resolveFrom: 'cwd',
44+
assets: {
45+
from: ['./public/*'],
46+
to: ['../../dist/lambda/public'],
47+
},
48+
}),
49+
],
50+
inject: [resolve(process.cwd(), "./zod-openapi-patch.js")],
3251
}
3352
esbuild
3453
.build({

0 commit comments

Comments
 (0)