From 035727b2e020b23f6e9b361fb1625584f6f27abf Mon Sep 17 00:00:00 2001 From: Tsu-ba-me Date: Thu, 24 Mar 2022 13:31:56 -0400 Subject: [PATCH] refactor(striker-ui-api): relocate buildGetRequestHandler --- .../{files/buildGetFiles.ts => buildGetRequestHandler.ts} | 6 +++--- .../src/lib/request_handlers/files/getFileDetail.ts | 4 ++-- striker-ui-api/src/lib/request_handlers/files/getFiles.ts | 4 ++-- 3 files changed, 7 insertions(+), 7 deletions(-) rename striker-ui-api/src/lib/request_handlers/{files/buildGetFiles.ts => buildGetRequestHandler.ts} (85%) diff --git a/striker-ui-api/src/lib/request_handlers/files/buildGetFiles.ts b/striker-ui-api/src/lib/request_handlers/buildGetRequestHandler.ts similarity index 85% rename from striker-ui-api/src/lib/request_handlers/files/buildGetFiles.ts rename to striker-ui-api/src/lib/request_handlers/buildGetRequestHandler.ts index 1def7b7b..e74f82be 100644 --- a/striker-ui-api/src/lib/request_handlers/files/buildGetFiles.ts +++ b/striker-ui-api/src/lib/request_handlers/buildGetRequestHandler.ts @@ -1,8 +1,8 @@ import { Request, Response } from 'express'; -import { dbQuery } from '../../accessDB'; +import { dbQuery } from '../accessDB'; -const buildGetFiles = +const buildGetRequestHandler = (query: string | ((request: Request) => string)) => (request: Request, response: Response) => { console.log('Calling CLI script to get data.'); @@ -30,4 +30,4 @@ const buildGetFiles = response.json(queryStdout); }; -export default buildGetFiles; +export default buildGetRequestHandler; diff --git a/striker-ui-api/src/lib/request_handlers/files/getFileDetail.ts b/striker-ui-api/src/lib/request_handlers/files/getFileDetail.ts index a8c0da0e..3a962ab5 100644 --- a/striker-ui-api/src/lib/request_handlers/files/getFileDetail.ts +++ b/striker-ui-api/src/lib/request_handlers/files/getFileDetail.ts @@ -1,7 +1,7 @@ -import buildGetFiles from './buildGetFiles'; +import buildGetRequestHandler from '../buildGetRequestHandler'; import buildQueryFilesDetail from './buildQueryFilesDetail'; -const getFileDetail = buildGetFiles((request) => +const getFileDetail = buildGetRequestHandler((request) => buildQueryFilesDetail({ filesUUID: [request.params.fileUUID] }), ); diff --git a/striker-ui-api/src/lib/request_handlers/files/getFiles.ts b/striker-ui-api/src/lib/request_handlers/files/getFiles.ts index 7665c7e3..b1a59dd5 100644 --- a/striker-ui-api/src/lib/request_handlers/files/getFiles.ts +++ b/striker-ui-api/src/lib/request_handlers/files/getFiles.ts @@ -1,7 +1,7 @@ -import buildGetFiles from './buildGetFiles'; +import buildGetRequestHandler from '../buildGetRequestHandler'; import buildQueryFilesDetail from './buildQueryFilesDetail'; -const getFiles = buildGetFiles((request) => { +const getFiles = buildGetRequestHandler((request) => { const { filesUUID } = request.body; let query = `