Skip to content

Commit a87b874

Browse files
committed
tooling updates
1 parent ba0d6b1 commit a87b874

File tree

6 files changed

+260
-11
lines changed

6 files changed

+260
-11
lines changed

cloudformation/iam.yml

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ Parameters:
1010
LambdaFunctionName:
1111
Type: String
1212
AllowedPattern: ^[a-zA-Z0-9]+[a-zA-Z0-9-]+[a-zA-Z0-9]+$
13+
SesEmailDomain:
14+
Type: String
1315
Resources:
1416
ApiLambdaIAMRole:
1517
Type: AWS::IAM::Role
@@ -24,6 +26,21 @@ Resources:
2426
Service:
2527
- lambda.amazonaws.com
2628
Policies:
29+
- PolicyDocument:
30+
Version: '2012-10-17'
31+
Statement:
32+
- Action:
33+
- ses:SendEmail
34+
- ses:SendRawEmail
35+
Effect: Allow
36+
Resource: "*"
37+
Condition:
38+
StringEquals:
39+
ses:FromAddress: !Sub "membership@${SesEmailDomain}"
40+
ForAllValues:StringLike:
41+
ses:Recipients:
42+
- "*@illinois.edu"
43+
PolicyName: ses-membership
2744
- PolicyDocument:
2845
Version: '2012-10-17'
2946
Statement:
@@ -85,4 +102,4 @@ Outputs:
85102
Value:
86103
Fn::GetAtt:
87104
- ApiLambdaIAMRole
88-
- Arn
105+
- Arn

cloudformation/main.yml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,10 @@ Mappings:
3232
General:
3333
dev:
3434
LogRetentionDays: 7
35+
SesDomain: "aws.qa.acmuiuc.org"
3536
prod:
3637
LogRetentionDays: 365
38+
SesDomain: "acm.illinois.edu"
3739
ApiGwConfig:
3840
dev:
3941
ApiCertificateArn: arn:aws:acm:us-east-1:427040638965:certificate/63ccdf0b-d2b5-44f0-b589-eceffb935c23
@@ -71,6 +73,7 @@ Resources:
7173
Parameters:
7274
RunEnvironment: !Ref RunEnvironment
7375
LambdaFunctionName: !Sub ${ApplicationPrefix}-lambda
76+
SesEmailDomain: !FindInMap [General, !Ref RunEnvironment, SesDomain]
7477

7578
AppLogGroups:
7679
Type: AWS::Serverless::Application
@@ -127,6 +130,10 @@ Resources:
127130
Minify: true
128131
OutExtension:
129132
- .js=.mjs
133+
Loader:
134+
- .png=file
135+
- .pkpass=file
136+
- .json=file
130137
Target: "es2022"
131138
Sourcemap: false
132139
EntryPoints:

generate_jwt.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ const payload = {
1818
groups: ["0"],
1919
idp: "https://login.microsoftonline.com",
2020
ipaddr: "192.168.1.1",
21-
name: "John Doe",
21+
name: "Doe, John",
2222
oid: "00000000-0000-0000-0000-000000000000",
2323
rh: "rh-value",
2424
scp: "user_impersonation",

src/api/esbuild.config.js

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
import { build, context } from 'esbuild';
2+
import { readFileSync } from 'fs';
3+
import { resolve } from 'path';
4+
5+
const isWatching = !!process.argv.includes('--watch')
6+
const nodePackage = JSON.parse(readFileSync(resolve(process.cwd(), 'package.json'), 'utf8'));
7+
8+
const buildOptions = {
9+
entryPoints: [resolve(process.cwd(), 'index.ts')],
10+
outfile: resolve(process.cwd(), '../', '../', 'dist_devel', 'index.js'),
11+
bundle: true,
12+
platform: 'node',
13+
format: 'esm',
14+
external: [
15+
Object.keys(nodePackage.dependencies ?? {}),
16+
Object.keys(nodePackage.peerDependencies ?? {}),
17+
Object.keys(nodePackage.devDependencies ?? {}),
18+
].flat(),
19+
loader: {
20+
'.png': 'file', // Add this line to specify a loader for .png files
21+
},
22+
};
23+
24+
if (isWatching) {
25+
context(buildOptions).then(ctx => {
26+
if (isWatching) {
27+
ctx.watch();
28+
} else {
29+
ctx.rebuild();
30+
}
31+
});
32+
} else {
33+
build(buildOptions)
34+
}

src/api/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
"type": "module",
99
"scripts": {
1010
"build": "tsc",
11-
"dev": "cross-env LOG_LEVEL=debug tsx watch index.ts",
11+
"dev": "cross-env LOG_LEVEL=debug concurrently --names 'esbuild,server' 'node esbuild.config.js --watch' 'cd ../../dist_devel && nodemon index.js'",
1212
"typecheck": "tsc --noEmit",
1313
"lint": "eslint . --ext .ts --cache",
1414
"prettier": "prettier --check *.ts **/*.ts",

0 commit comments

Comments
 (0)