From 48ecf478f74fb05d1b7d70064460c8bbe3becb87 Mon Sep 17 00:00:00 2001 From: Duncan X Simpson Date: Wed, 1 Jul 2020 23:32:51 -0700 Subject: [PATCH] refactor testing --- src/app.ts | 3 ++- src/requests.ts | 4 ++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/app.ts b/src/app.ts index 947ad92..f9bfa2a 100644 --- a/src/app.ts +++ b/src/app.ts @@ -9,7 +9,8 @@ app.use(express.json()); app.get("/api/getRequests", async (request, response) => { var requestCount = ( request.query.count ? parseInt(request.query.count as string, 10) : 5 ); - requests.getRequests(requestCount,response); + requests.getRequests(requestCount).then((val: any) => console.log(val)); + response.send(requests.getRequests(requestCount)); }); app.get("/api/getAllRequests", async (request, response) => { diff --git a/src/requests.ts b/src/requests.ts index ab4c784..a056da1 100644 --- a/src/requests.ts +++ b/src/requests.ts @@ -8,10 +8,10 @@ const getRequestsQuery = { text: "SELECT * FROM requests_vw LIMIT $1" } -export async function getRequests(count: number, response: express.Response) { +export async function getRequests(count: number) { var query = Object.assign(getRequestsQuery, { values: [count] }); db.query(query) - .then((result: pg.QueryResult) => response.send(result.rows)) + .then((result: pg.QueryResult) => result.rows) .catch((e: any) => console.error(e.stack)); };