🧑‍💻 Add simple filesystem file provider

- Allows parsing files from a local folder
This commit is contained in:
2023-08-27 18:01:28 +02:00
parent 0cb55eaf68
commit 7705a299a0

View File

@ -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;
}
}