mirror of
				https://gitlab.com/comunic/comunicapiv2
				synced 2025-10-31 17:44:03 +00:00 
			
		
		
		
	Add support for POST requests
This commit is contained in:
		| @@ -1,4 +1,3 @@ | |||||||
| import { Response, Request } from "express"; |  | ||||||
| import { RequestHandler } from "../models/RequestHandler"; | import { RequestHandler } from "../models/RequestHandler"; | ||||||
|  |  | ||||||
| /** | /** | ||||||
|   | |||||||
							
								
								
									
										11
									
								
								src/main.ts
									
									
									
									
									
								
							
							
						
						
									
										11
									
								
								src/main.ts
									
									
									
									
									
								
							| @@ -26,10 +26,15 @@ async function init() { | |||||||
| 	// Process the list of routes | 	// Process the list of routes | ||||||
| 	Routes.forEach(route => { | 	Routes.forEach(route => { | ||||||
| 		 | 		 | ||||||
|  | 		const cb = (req : express.Request, res : express.Response)=> { | ||||||
|  | 			route.cb(new RequestHandler(req, res)); | ||||||
|  | 		}; | ||||||
|  |  | ||||||
| 		if(route.type == RouteType.GET) | 		if(route.type == RouteType.GET) | ||||||
| 			app.get(route.path, (req : express.Request, res : express.Response)=> { | 			app.get(route.path, cb); | ||||||
| 				route.cb(new RequestHandler(req, res)); | 		 | ||||||
| 			}) | 		else | ||||||
|  | 			app.post(route.path, cb); | ||||||
|  |  | ||||||
| 	}) | 	}) | ||||||
|  |  | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user