Skip to content

Commit

Permalink
cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
devksingh4 committed Feb 1, 2025
1 parent 26bba3a commit 52e5e41
Show file tree
Hide file tree
Showing 7 changed files with 13 additions and 270 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
"@typescript-eslint/parser": "^8.0.1",
"@vitejs/plugin-react": "^4.3.1",
"@vitest/ui": "^2.0.5",
"aws-sdk-client-mock": "^4.0.1",
"aws-sdk-client-mock": "^4.1.0",
"concurrently": "^9.1.2",
"cross-env": "^7.0.3",
"esbuild": "^0.23.0",
Expand Down
6 changes: 0 additions & 6 deletions src/api/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ import { STSClient, GetCallerIdentityCommand } from "@aws-sdk/client-sts";
import NodeCache from "node-cache";
import { DynamoDBClient } from "@aws-sdk/client-dynamodb";
import { SecretsManagerClient } from "@aws-sdk/client-secrets-manager";
import { SESClient } from "@aws-sdk/client-ses";
import mobileWalletRoute from "./routes/mobileWallet.js";

dotenv.config();
Expand All @@ -37,10 +36,6 @@ async function init() {
region: genericConfig.AwsRegion,
});

const sesClient = new SESClient({
region: genericConfig.AwsRegion,
});

const app: FastifyInstance = fastify({
logger: {
level: process.env.LOG_LEVEL || "info",
Expand Down Expand Up @@ -88,7 +83,6 @@ async function init() {
app.nodeCache = new NodeCache({ checkperiod: 30 });
app.dynamoClient = dynamoClient;
app.secretsManagerClient = secretsManagerClient;
app.sesClient = sesClient;
app.addHook("onRequest", (req, _, done) => {
req.startTime = now();
const hostname = req.hostname;
Expand Down
5 changes: 2 additions & 3 deletions src/api/sqs/handlers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ export const emailMembershipPassHandler: SQSHandlerFunction<
const clients = {
smClient: new SecretsManagerClient(commonConfig),
dynamoClient: new DynamoDBClient(commonConfig),
sesClient: new SESClient(commonConfig),
};
const entraIdToken = await getEntraIdToken(
clients,
Expand All @@ -46,8 +45,8 @@ export const emailMembershipPassHandler: SQSHandlerFunction<
if (runEnvironment === "dev" && email === "testinguser@illinois.edu") {
return;
}
await clients.sesClient.send(emailCommand);
return;
const sesClient = new SESClient(commonConfig);
return await sesClient.send(emailCommand);
};

export const pingHandler: SQSHandlerFunction<
Expand Down
5 changes: 1 addition & 4 deletions src/api/sqs/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,6 @@ import { z, ZodError } from "zod";
import pino from "pino";
import { emailMembershipPassHandler, pingHandler } from "./handlers.js";
import { ValidationError } from "../../common/errors/index.js";
import { SecretsManagerClient } from "@aws-sdk/client-secrets-manager";
import { SESClient } from "@aws-sdk/client-ses";
import { DynamoDBClient } from "@aws-sdk/client-dynamodb";
import { RunEnvironment } from "../../common/roles.js";
import { environmentConfig } from "../../common/config.js";

Expand All @@ -28,7 +25,7 @@ export type SQSHandlerFunction<T extends AvailableSQSFunctions> = (
payload: z.infer<(typeof sqsPayloadSchemas)[T]>["payload"],
metadata: SQSMessageMetadata,
logger: pino.Logger,
) => Promise<void>;
) => Promise<any>;

const handlers: SQSFunctionPayloadTypes = {
[AvailableSQSFunctions.EmailMembershipPass]: emailMembershipPassHandler,
Expand Down
3 changes: 1 addition & 2 deletions src/api/types.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ import { ConfigType } from "../common/config.js";
import NodeCache from "node-cache";
import { DynamoDBClient } from "@aws-sdk/client-dynamodb";
import { SecretsManagerClient } from "@aws-sdk/client-secrets-manager";
import { SESClient } from "@aws-sdk/client-ses";
import { SQSClient } from "@aws-sdk/client-sqs";

declare module "fastify" {
interface FastifyInstance {
authenticate: (
Expand All @@ -27,7 +27,6 @@ declare module "fastify" {
environmentConfig: ConfigType;
nodeCache: NodeCache;
dynamoClient: DynamoDBClient;
sesClient: SESClient;
sqsClient?: SQSClient;
secretsManagerClient: SecretsManagerClient;
}
Expand Down
50 changes: 0 additions & 50 deletions tests/unit/sqs/emailMembershipPass.test.ts

This file was deleted.

Loading

0 comments on commit 52e5e41

Please sign in to comment.