From 7705a299a06e6dd4e0a3caec5af5442b68c3295e Mon Sep 17 00:00:00 2001 From: minie4 Date: Sun, 27 Aug 2023 18:01:28 +0200 Subject: [PATCH] =?UTF-8?q?=F0=9F=A7=91=E2=80=8D=F0=9F=92=BB=20Add=20simpl?= =?UTF-8?q?e=20filesystem=20file=20provider?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Allows parsing files from a local folder --- server/parser/filesystem.js | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 server/parser/filesystem.js diff --git a/server/parser/filesystem.js b/server/parser/filesystem.js new file mode 100644 index 0000000..c868667 --- /dev/null +++ b/server/parser/filesystem.js @@ -0,0 +1,24 @@ +import fs from "fs"; + +/* +This file provider allows the application to use a local folder containing +parsable (.html) files, instead of downloading them from the internet. + +This can be especially useful for development. +*/ + +export class FileSystemClient { + constructor(path) { + this.path = path; + } + + getFiles() { + const contents = []; + const files = fs.readdirSync(this.path); + for (const file of files) { + const data = fs.readFileSync(this.path + "/" + file).toString(); + contents.push(data); + } + return contents; + } +}