Skip to content

Commit

Permalink
Merge pull request #43 from intelligentnode/23-doc-parser-document
Browse files Browse the repository at this point in the history
Added document for document parsers
  • Loading branch information
intelligentnode authored Sep 27, 2023
2 parents 8e03d4a + b014906 commit 4e18ac6
Showing 1 changed file with 60 additions and 0 deletions.
60 changes: 60 additions & 0 deletions intelliserver/api/parser/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,36 @@ const mammoth = require('mammoth');
const router = express.Router();
const upload = multer();

/**
* @swagger
* /parser/pdf_to_text:
* post:
* tags:
* - Parsers
* summary: Convert a PDF document to text with page-wise data.
*
* security:
* - ApiKeyAuth: []
*
* requestBody:
* required: true
* content:
* multipart/form-data:
* schema:
* type: object
* properties:
* pdf:
* type: string
* format: binary
* description: PDF file to be converted.
* responses:
* 200:
* description: Successfully converted PDF to text.
* 400:
* description: Bad request or missing PDF file.
* 500:
* description: Internal server error during PDF conversion.
*/
router.post('/pdf_to_text', upload.single('pdf'), async (req, res) => {
if (!req.file) {
return res.status(400).json({ status: 'ERROR', message: 'PDF document not provided' });
Expand Down Expand Up @@ -64,6 +94,36 @@ router.post('/pdf_to_text', upload.single('pdf'), async (req, res) => {

});

/**
* @swagger
* /parser/word_to_text:
* post:
* tags:
* - Parsers
* summary: Convert a Word document to text.
*
* security:
* - ApiKeyAuth: []
*
* requestBody:
* required: true
* content:
* multipart/form-data:
* schema:
* type: object
* properties:
* doc:
* type: string
* format: binary
* description: Word document to be converted.
* responses:
* 200:
* description: Successfully converted Word to text.
* 400:
* description: Bad request or missing Word document.
* 500:
* description: Internal server error during Word conversion.
*/
router.post('/word_to_text', upload.single('doc'), async (req, res) => {
if (!req.file) {
return res.status(400).json({ status: 'ERROR', message: 'Word document not provided' });
Expand Down

0 comments on commit 4e18ac6

Please sign in to comment.