refactor testing
This commit is contained in:
		
							parent
							
								
									fcf4f092e8
								
							
						
					
					
						commit
						48ecf478f7
					
				
					 2 changed files with 4 additions and 3 deletions
				
			
		|  | @ -9,7 +9,8 @@ app.use(express.json()); | ||||||
| 
 | 
 | ||||||
| app.get("/api/getRequests", async (request, response) => { | app.get("/api/getRequests", async (request, response) => { | ||||||
| 	var requestCount = ( request.query.count ? parseInt(request.query.count as string, 10) : 5 ); | 	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) => { | app.get("/api/getAllRequests", async (request, response) => { | ||||||
|  |  | ||||||
|  | @ -8,10 +8,10 @@ const getRequestsQuery = { | ||||||
| 	text: "SELECT * FROM requests_vw LIMIT $1" | 	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] }); | 	var query = Object.assign(getRequestsQuery, { values: [count] }); | ||||||
| 	db.query(query) | 	db.query(query) | ||||||
| 	.then((result: pg.QueryResult) => response.send(result.rows)) | 	.then((result: pg.QueryResult) => result.rows) | ||||||
| 	.catch((e: any) => console.error(e.stack)); | 	.catch((e: any) => console.error(e.stack)); | ||||||
| }; | }; | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue