Skip to content

Commit

Permalink
Remove server-side components
Browse files Browse the repository at this point in the history
  • Loading branch information
robknight committed Jul 5, 2024
1 parent a929a3d commit 6418aab
Show file tree
Hide file tree
Showing 4 changed files with 1 addition and 140 deletions.
59 changes: 0 additions & 59 deletions apps/passport-server/src/routing/routes/genericIssuanceRoutes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,8 @@ import {
GenericIssuanceUpsertPipelineRequest,
GenericIssuanceUpsertPipelineResponseValue,
ListFeedsResponseValue,
PipelineGetManualCheckInsResponseValue,
PipelineInfoRequest,
PipelineInfoResponseValue,
PipelineSetManualCheckInStateRequest,
PipelineSetManualCheckInStateResponseValue,
PodboxTicketActionPreCheckRequest,
PodboxTicketActionRequest,
PodboxTicketActionResponseValue,
Expand Down Expand Up @@ -221,62 +218,6 @@ export function initGenericIssuanceRoutes(
res.json(result satisfies PipelineInfoResponseValue);
});

app.get(
"/generic-issuance/api/manual-checkin/:pipelineID/:key",
async (req, res) => {
checkGenericIssuanceServiceStarted(genericIssuanceService);
const pipelineID = checkUrlParam(req, "pipelineID");
if (pipelineID !== "c00d3470-7ff8-4060-adc1-e9487d607d42") {
logger(
`[ROUTES] Received invalid manual checkin list request for pipeline ${pipelineID}`
);
throw new PCDHTTPError(404);
}

if (
checkUrlParam(req, "key") !== process.env.MANUAL_CHECKIN_API_KEY ||
!process.env.MANUAL_CHECKIN_API_KEY
) {
throw new PCDHTTPError(401);
}

const result =
await genericIssuanceService.handleGetManualCheckIns(pipelineID);

res.json(result satisfies PipelineGetManualCheckInsResponseValue);
}
);

app.post(
"/generic-issuance/api/manual-checkin/:pipelineID/:key",
async (req, res) => {
checkGenericIssuanceServiceStarted(genericIssuanceService);
const pipelineID = checkUrlParam(req, "pipelineID");
if (pipelineID !== "c00d3470-7ff8-4060-adc1-e9487d607d42") {
logger(
`[ROUTES] Received invalid manual checkin update request for pipeline ${pipelineID}`
);
throw new PCDHTTPError(404);
}

if (
checkUrlParam(req, "key") !== process.env.MANUAL_CHECKIN_API_KEY ||
!process.env.MANUAL_CHECKIN_API_KEY
) {
throw new PCDHTTPError(401);
}

const reqBody = req.body as PipelineSetManualCheckInStateRequest;
const result = await genericIssuanceService.handleSetManualCheckInState(
pipelineID,
reqBody.ticketId,
reqBody.checkInState
);

res.json(result satisfies PipelineSetManualCheckInStateResponseValue);
}
);

/**
* Authenticated by PCD so doesn't need auth.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,7 @@ import {
ListFeedsResponseValue,
PipelineDefinition,
PipelineEmailType,
PipelineGetManualCheckInsResponseValue,
PipelineInfoResponseValue,
PipelineSetManualCheckInStateResponseValue,
PodboxTicketActionPreCheckRequest,
PodboxTicketActionRequest,
PodboxTicketActionResponseValue,
Expand Down Expand Up @@ -302,24 +300,6 @@ export class GenericIssuanceService {
);
}

public async handleSetManualCheckInState(
pipelineId: string,
ticketId: string,
checkInState: boolean
): Promise<PipelineSetManualCheckInStateResponseValue> {
return this.pipelineSubservice.handleSetManualCheckInState(
pipelineId,
ticketId,
checkInState
);
}

public async handleGetManualCheckIns(
pipelineId: string
): Promise<PipelineGetManualCheckInsResponseValue> {
return this.pipelineSubservice.handleGetManualCheckIns(pipelineId);
}

public async validateEmailAndPretixOrderCode(
email: string,
code: string
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,8 @@ import {
GenericIssuanceSemaphoreGroupRootResponseValue,
GenericIssuanceValidSemaphoreGroupResponseValue,
ListFeedsResponseValue,
PipelineGetManualCheckInsResponseValue,
PipelineInfoConsumer,
PipelineInfoResponseValue,
PipelineSetManualCheckInStateResponseValue,
PodboxTicketActionPreCheckRequest,
PodboxTicketActionRequest,
PodboxTicketActionResponseValue,
Expand All @@ -23,10 +21,7 @@ import { IPipelineConsumerDB } from "../../../database/queries/pipelineConsumerD
import { PCDHTTPError } from "../../../routing/pcdHttpError";
import { logger } from "../../../util/logger";
import { traceFlattenedObject, traced } from "../../telemetryService";
import {
ensureCheckinCapability,
isCheckinCapability
} from "../capabilities/CheckinCapability";
import { isCheckinCapability } from "../capabilities/CheckinCapability";
import {
FeedIssuanceCapability,
ensureFeedIssuanceCapability,
Expand Down Expand Up @@ -525,39 +520,4 @@ export class PipelineAPISubservice {
}
);
}

public async handleSetManualCheckInState(
pipelineId: string,
ticketId: string,
checkInState: boolean
): Promise<PipelineSetManualCheckInStateResponseValue> {
return traced(SERVICE_NAME, "handleSetManualCheckInState", async (span) => {
span?.setAttribute("pipeline_id", pipelineId);
const pipelineSlot =
await this.pipelineSubservice.ensurePipelineSlotExists(pipelineId);
const pipeline =
await this.pipelineSubservice.ensurePipelineStarted(pipelineId);
tracePipeline(pipelineSlot.definition);
const checkInCapability = ensureCheckinCapability(pipeline);

checkInCapability.setManualCheckInState(ticketId, checkInState, "manual");
return { checkInState };
});
}

public async handleGetManualCheckIns(
pipelineId: string
): Promise<PipelineGetManualCheckInsResponseValue> {
return traced(SERVICE_NAME, "handleGetManualCheckInState", async (span) => {
span?.setAttribute("pipeline_id", pipelineId);
const pipelineSlot =
await this.pipelineSubservice.ensurePipelineSlotExists(pipelineId);
const pipeline =
await this.pipelineSubservice.ensurePipelineStarted(pipelineId);
tracePipeline(pipelineSlot.definition);
const checkInCapability = ensureCheckinCapability(pipeline);

return { checkIns: await checkInCapability.getManualCheckinSummary() };
});
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,9 @@ import {
ListFeedsResponseValue,
PipelineDefinition,
PipelineEmailType,
PipelineGetManualCheckInsResponseValue,
PipelineHistoryEntry,
PipelineInfoResponseValue,
PipelineLoadSummary,
PipelineSetManualCheckInStateResponseValue,
PodboxTicketActionPreCheckRequest,
PodboxTicketActionRequest,
PodboxTicketActionResponseValue,
Expand Down Expand Up @@ -531,22 +529,4 @@ export class PipelineSubservice {
pipelineId
);
}

public async handleSetManualCheckInState(
pipelineId: string,
ticketId: string,
checkInState: boolean
): Promise<PipelineSetManualCheckInStateResponseValue> {
return this.pipelineAPISubservice.handleSetManualCheckInState(
pipelineId,
ticketId,
checkInState
);
}

public async handleGetManualCheckIns(
pipelineId: string
): Promise<PipelineGetManualCheckInsResponseValue> {
return this.pipelineAPISubservice.handleGetManualCheckIns(pipelineId);
}
}

0 comments on commit 6418aab

Please sign in to comment.