Skip to content

Commit

Permalink
Merge branch 'master' into Streamline-file-upload
Browse files Browse the repository at this point in the history
  • Loading branch information
GavinLynch04 committed Dec 4, 2023
2 parents 02ddcd5 + d87c6eb commit 5b1fc9c
Show file tree
Hide file tree
Showing 14 changed files with 564 additions and 770 deletions.
4 changes: 1 addition & 3 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.

# dependencies
/node_modules
/packages/frontend/node_modules
/packages/backend/node_modules
node_modules
/.pnp
.pnp.js

Expand Down
33 changes: 33 additions & 0 deletions packages/backend/backend.js
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,28 @@ app.post("/login", async (req, res) => {
res.status(500).json({ error: "Internal server error" });
}
});
const popupDataSchema = new mongoose.Schema({
// Define the schema based on the data structure of your popup
// Example:
date: { type: Date, required: true },
content: { type: String, required: true },
// Add other fields as necessary
});

const PopupData = mongoose.model('PopupData', popupDataSchema);

app.post('/savePopupData', verifyToken, async (req, res) => {
try {
const newPopupData = new PopupData(req.body); // Create a new instance of PopupData model with request body data
await newPopupData.save(); // Save the new instance to the database

res.status(200).json({ message: 'Popup data saved successfully' });
} catch (err) {
console.error('Error saving popup data:', err);
res.status(500).json({ error: 'Internal Server Error' });
}
});


app.get("/process", verifyToken, async (req, res) => {
const listFiles = [relativeFilePath];
Expand Down Expand Up @@ -238,6 +260,17 @@ app.get("/process", verifyToken, async (req, res) => {
});
});

app.get('/getPopupData', verifyToken, async (req, res) => {
try {
const popupData = await PopupData.find({}); // Fetch all documents from PopupData collection
res.json(popupData);
} catch (err) {
console.error('Error fetching popup data:', err);
res.status(500).json({ error: 'Internal Server Error' });
}
});


app.listen(port, () => {
console.log(`Server is running on port ${port}`);
});
Expand Down
Loading

0 comments on commit 5b1fc9c

Please sign in to comment.