const fs = require('fs')
const path = require('path')
const logger = require('./logger')()
/*
* This class will output any files in the assets folder
* Eg. `./assets/{foldername}/{filename}`
*
* You can also create a function that will output html
* On the client side the `main.js` will use `innerHTML = {output}`
*/
class ReadFile {
constructor(x) {
try {
this.object = {
baseUrl: x.baseUrl,
mime: '',
main: '',
types: x.mime,
layouts: {
header: fs.readFileSync('./views/layouts/header.html', 'utf-8'),
loading: fs.readFileSync('./views/layouts/loading.html', 'utf-8'),
footer: fs.readFileSync('./views/layouts/footer.html', 'utf-8')
}
}
for (const key in this.object.layouts) {this.object.layouts[key] = this.#RemoveSpaces(this.object.layouts[key])}
} catch(err) {
logger.Error(err)
}
}
GetMain(x) {
const data = {
header: '',
footer: `