2024-10-13 15:52:27 +00:00
|
|
|
const fs = require('fs');
|
|
|
|
const path = require('path');
|
2024-10-13 16:30:51 +00:00
|
|
|
global.marked = require('marked'); //note: this is used in other files
|
2024-10-13 15:52:27 +00:00
|
|
|
require('dotenv').config(); // Load environment variables from .env file
|
|
|
|
|
2024-10-13 16:30:51 +00:00
|
|
|
|
2024-10-13 15:52:27 +00:00
|
|
|
const express = require('express');
|
2024-10-13 16:30:51 +00:00
|
|
|
global.app = express();
|
2024-10-13 15:52:27 +00:00
|
|
|
const PORT = process.env.PORT || 3000;
|
|
|
|
|
|
|
|
// Specify the folder containing the .js files
|
|
|
|
const folderPath = './addon-scripts'; // Change this to your folder path
|
|
|
|
|
|
|
|
// Read the directory
|
|
|
|
fs.readdir(folderPath, (err, files) => {
|
|
|
|
if (err) {
|
|
|
|
console.error('Error reading directory:', err);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Filter for .js files
|
|
|
|
const jsFiles = files.filter(file => path.extname(file) === '.js');
|
|
|
|
|
|
|
|
// Read and evaluate each .js file
|
|
|
|
jsFiles.forEach(file => {
|
|
|
|
const filePath = path.join(folderPath, file);
|
|
|
|
|
|
|
|
fs.readFile(filePath, 'utf8', (err, data) => {
|
|
|
|
if (err) {
|
|
|
|
console.error(`Error reading file ${file}:`, err);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
try {
|
2024-10-13 16:30:51 +00:00
|
|
|
Function(data)()
|
2024-10-13 15:52:27 +00:00
|
|
|
} catch (e) {
|
|
|
|
console.error(`Error executing ${file}:`, e);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
app.listen(PORT, () => {
|
|
|
|
console.log(`Website server is running on port ${PORT}`);
|
|
|
|
});
|