summaryrefslogtreecommitdiffstats
path: root/server
diff options
context:
space:
mode:
authorLibravatarLibravatar Biswakalyan Bhuyan <biswa@surgot.in> 2024-06-28 20:57:46 +0530
committerLibravatarLibravatar Biswakalyan Bhuyan <biswa@surgot.in> 2024-06-28 20:57:46 +0530
commitac0257db671bce0ae2ba160ba93018317184256a (patch)
treebb5c26c620f28059f1c447fb22473ab4e2f4f4ef /server
parent4e0e7ee9d776d4a043ebd48181b073aa92462968 (diff)
downloadinsta-local-ac0257db671bce0ae2ba160ba93018317184256a.tar.gz
insta-local-ac0257db671bce0ae2ba160ba93018317184256a.tar.bz2
insta-local-ac0257db671bce0ae2ba160ba93018317184256a.zip
Revert "adding the influencer page and adding the funcitons in it"
This reverts commit 4a580e70d713ee80a0093663b665402e1bef5fc9.
Diffstat (limited to 'server')
-rw-r--r--server/server.js25
1 files changed, 8 insertions, 17 deletions
diff --git a/server/server.js b/server/server.js
index 5f714e4..b795846 100644
--- a/server/server.js
+++ b/server/server.js
@@ -1,3 +1,4 @@
+require('dotenv').config(); // Add this line at the top
const express = require('express');
const { exec } = require('child_process');
const path = require('path');
@@ -8,7 +9,7 @@ const bodyParser = require('body-parser');
const app = express();
const port = 5001;
-const adminPassword = process.env.ADMIN_PASSWORD;
+const adminPassword = process.env.ADMIN_PASSWORD; // Use environment variable
app.use(express.json());
app.use(cors());
@@ -113,25 +114,15 @@ const authenticate = (req, res, next) => {
// Endpoint to get influencers
app.get('/influencers', authenticate, (req, res) => {
- try {
- const influencersData = JSON.parse(fs.readFileSync(path.join(__dirname, 'influencers.json'), 'utf8'));
- res.json(influencersData.profiles);
- } catch (error) {
- console.error('Error fetching influencers:', error);
- res.status(500).json({ error: 'Error fetching influencers' });
- }
+ const influencers = JSON.parse(fs.readFileSync(path.join(__dirname, 'influencers.json'), 'utf8')).profiles;
+ res.json(influencers);
});
-// Endpoint to update influencersData
+// Endpoint to update influencers
app.post('/influencers', authenticate, (req, res) => {
- try {
- const { profiles } = req.body;
- const influencersData = { profiles };
- fs.writeFileSync(path.join(__dirname, 'influencers.json'), JSON.stringify(updatedData, null, 2));
- } catch (error) {
- console.error('Error updating influencers:', error);
- res.status(500).json({ error: 'Error updating influencers' });
- }
+ const { profiles } = req.body;
+ fs.writeFileSync(path.join(__dirname, 'influencers.json'), JSON.stringify({ profiles }, null, 2));
+ res.status(200).json({ message: 'Influencers updated successfully' });
});
// Endpoint to export influencers JSON