Skip to content

Commit

Permalink
refactor(plugins): move shared wordextractor class to upper scope
Browse files Browse the repository at this point in the history
  • Loading branch information
Fdawgs committed Oct 29, 2023
1 parent 96d9d1d commit db980d0
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions src/plugins/doc-to-txt/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
const fp = require("fastify-plugin");
const WordExtractor = require("word-extractor");

const wordExtractor = new WordExtractor();

/**
* @author Frazer Smith
* @description Pre-handler plugin that uses Word-Extractor to convert Buffer containing
Expand All @@ -11,8 +13,6 @@ const WordExtractor = require("word-extractor");
* @param {import("fastify").FastifyInstance} server - Fastify instance.
*/
async function plugin(server) {
const wordExtractor = new WordExtractor();

server
.decorateRequest("conversionResults", null)
.addHook("onRequest", async (req) => {
Expand Down
4 changes: 2 additions & 2 deletions src/plugins/docx-to-html/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ const { JSDOM } = require("jsdom");
const { convertToHtml } = require("mammoth");
const WordExtractor = require("word-extractor");

const wordExtractor = new WordExtractor();

/**
* @author Frazer Smith
* @description Pre-handler plugin that uses Mammoth and Word-Extractor to convert Buffer containing
Expand All @@ -15,8 +17,6 @@ const WordExtractor = require("word-extractor");
* @param {import("fastify").FastifyInstance} server - Fastify instance.
*/
async function plugin(server) {
const wordExtractor = new WordExtractor();

server
.decorateRequest("conversionResults", null)
.addHook("onRequest", async (req) => {
Expand Down

0 comments on commit db980d0

Please sign in to comment.