refactor testing

pull/1/head
Duncan X Simpson 2020-07-01 23:32:51 -07:00
parent fcf4f092e8
commit 48ecf478f7
2 changed files with 4 additions and 3 deletions

View File

@ -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) => {

View File

@ -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));
};