From aa23792fe73ed3accd7f6f406e4a2282f0a4acf8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dafydd=20Ll=C5=B7r=20Pearson?= Date: Tue, 17 Oct 2023 11:34:23 +0100 Subject: [PATCH] chore: Convert remain /admin endpoint to client --- api.planx.uk/admin/session/csv.ts | 8 +++----- api.planx.uk/admin/session/html.ts | 12 +++++------- 2 files changed, 8 insertions(+), 12 deletions(-) diff --git a/api.planx.uk/admin/session/csv.ts b/api.planx.uk/admin/session/csv.ts index df4d348f45..c0c3f2f1c0 100644 --- a/api.planx.uk/admin/session/csv.ts +++ b/api.planx.uk/admin/session/csv.ts @@ -1,6 +1,6 @@ import { stringify } from "csv-stringify"; import { NextFunction, Request, Response } from "express"; -import { getClient } from "../../client"; +import { $api } from "../../client"; /** * @swagger @@ -26,8 +26,7 @@ export async function getCSVData( next: NextFunction, ) { try { - const $client = getClient(); - const responses = await $client.export.csvData(req.params.sessionId); + const responses = await $api.export.csvData(req.params.sessionId); if (req.query?.download) { stringify(responses, { @@ -70,8 +69,7 @@ export async function getRedactedCSVData( next: NextFunction, ) { try { - const $client = getClient(); - const redactedResponses = await $client.export.csvDataRedacted( + const redactedResponses = await $api.export.csvDataRedacted( req.params.sessionId, ); diff --git a/api.planx.uk/admin/session/html.ts b/api.planx.uk/admin/session/html.ts index a83a5e8245..493bd58dd5 100644 --- a/api.planx.uk/admin/session/html.ts +++ b/api.planx.uk/admin/session/html.ts @@ -1,5 +1,5 @@ import { generateApplicationHTML } from "@opensystemslab/planx-core"; -import { getClient } from "../../client"; +import { $api } from "../../client"; import type { RequestHandler } from "express"; import type { PlanXExportData } from "@opensystemslab/planx-core/types"; @@ -20,11 +20,10 @@ type HTMLExportHandler = RequestHandler<{ sessionId: string }, string>; */ export const getHTMLExport: HTMLExportHandler = async (req, res, next) => { try { - const $client = getClient(); - const session = await $client.session.find(req.params.sessionId); + const session = await $api.session.find(req.params.sessionId); if (!session) throw Error(`Unable to find session ${req.params.sessionId}`); - const responses = await $client.export.csvData(req.params.sessionId); + const responses = await $api.export.csvData(req.params.sessionId); const boundingBox = session.data.passport.data["property.boundary.site.buffered"]; @@ -61,11 +60,10 @@ export const getRedactedHTMLExport: HTMLExportHandler = async ( next, ) => { try { - const $client = getClient(); - const session = await $client.session.find(req.params.sessionId); + const session = await $api.session.find(req.params.sessionId); if (!session) throw Error(`Unable to find session ${req.params.sessionId}`); - const redactedResponses = await $client.export.csvDataRedacted( + const redactedResponses = await $api.export.csvDataRedacted( req.params.sessionId, ); const boundingBox =