From 85f37e8f5bc6e18fc35ebecffba664119350c774 Mon Sep 17 00:00:00 2001 From: Sneed Group Holder Date: Sun, 13 Oct 2024 11:30:51 -0500 Subject: [PATCH] fix tons of bugs! --- addon-scripts/1.js | 10 ++++++---- index.js | 9 ++++----- 2 files changed, 10 insertions(+), 9 deletions(-) diff --git a/addon-scripts/1.js b/addon-scripts/1.js index 79b7809..b371f1b 100644 --- a/addon-scripts/1.js +++ b/addon-scripts/1.js @@ -1,16 +1,18 @@ -const mainHTML = marked(`# Welcome to ContentCraft! +const mainHTML = global.marked.parse(`# Welcome to ContentCraft! ContentCraft is similar to WordPress, except different. You can do pretty much anything with it using the *"addon-scripts"* folder (like this page here, and making other pages!) We included a few basic libraries in the index.js for you, but feel free to - add more to your addons, such as quick.db if you need to spin up a database. + add more libraries into your addons, such as quick.db if you need to spin up a database. Have a great day. - From all of us at Sneed Group.`) + From all of us at Sneed Group. + + PS: PRO TIP - USE "global" WHEN YOU WANT TO USE VARIABLES CROSS-ADDON.`) -app.get('/', (req, res) => { +global.app.get('/', (req, res) => { res.send(mainHTML); }); \ No newline at end of file diff --git a/index.js b/index.js index 3f51bbc..72391ec 100644 --- a/index.js +++ b/index.js @@ -1,10 +1,11 @@ const fs = require('fs'); const path = require('path'); -const marked = require('marked'); //note: this is used in other files +global.marked = require('marked'); //note: this is used in other files require('dotenv').config(); // Load environment variables from .env file + const express = require('express'); -const app = express(); +global.app = express(); const PORT = process.env.PORT || 3000; // Specify the folder containing the .js files @@ -31,9 +32,7 @@ fs.readdir(folderPath, (err, files) => { } try { - // Create a new function and execute it - const func = new Function(data); - func(); // Call the function + Function(data)() } catch (e) { console.error(`Error executing ${file}:`, e); }