feat(ocr payment page) - added backend routes on app
This commit is contained in:
23
apps/Backend/src/routes/patientDataExtraction.ts
Normal file
23
apps/Backend/src/routes/patientDataExtraction.ts
Normal file
@@ -0,0 +1,23 @@
|
||||
import { Router } from "express";
|
||||
import type { Request, Response } from "express";
|
||||
const router = Router();
|
||||
import multer from "multer";
|
||||
import forwardToPatientDataExtractorService from "../services/patientDataExtractorService";
|
||||
|
||||
const upload = multer({ storage: multer.memoryStorage() });
|
||||
|
||||
router.post("/patientdataextract", upload.single("pdf"), async (req: Request, res: Response): Promise<any>=> {
|
||||
if (!req.file) {
|
||||
return res.status(400).json({ error: "No PDF file uploaded." });
|
||||
}
|
||||
|
||||
try {
|
||||
const result = await forwardToPatientDataExtractorService(req.file);
|
||||
res.json(result);
|
||||
} catch (err) {
|
||||
console.error(err);
|
||||
res.status(500).json({ error: "Extraction failed" });
|
||||
}
|
||||
});
|
||||
|
||||
export default router;
|
||||
Reference in New Issue
Block a user