ChandN162 / Money-11

0 stars 0 forks source link

Money 11 #1

Open ChandN162 opened 4 days ago

ChandN162 commented 4 days ago

<!DOCTYPE html>

Earning Website

Welcome to the Earning Website

Complete tasks below to earn rewards:

Task 1: Watch a video

Task 2: Fill a survey

ChandN162 commented 4 days ago

const express = require('express'); const bodyParser = require('body-parser'); const app = express();

app.use(bodyParser.json()); app.use(express.static('public')); // Serve frontend files

// Fake user database let users = { user1: { points: 0 } };

// Endpoint to handle task completion app.post('/complete-task', (req, res) => { const { taskId } = req.body;

if (!taskId) return res.status(400).send({ message: 'Task ID is required' });

// Add points based on task
const pointsEarned = taskId === 1 ? 10 : 20;
users.user1.points += pointsEarned;

res.send({ message: `Task completed! You earned ${pointsEarned} points.` });

});

// Endpoint to get user points app.get('/points', (req, res) => { res.send({ points: users.user1.points }); });

// Start the server const PORT = 3000; app.listen(PORT, () => console.log(Server running on http://localhost:${PORT}));

ChandN162 commented 4 days ago

npm install mongoose

ChandN162 commented 4 days ago

const mongoose = require('mongoose'); mongoose.connect('mongodb://localhost:27017/earning-app', { useNewUrlParser: true, useUnifiedTopology: true });

const UserSchema = new mongoose.Schema({ name: String, points: Number });

const User = mongoose.model('User', UserSchema);

ChandN162 commented 4 days ago

npm install paypal-rest-sdk

ChandN162 commented 4 days ago

const paypal = require('paypal-rest-sdk');

paypal.configure({ mode: 'sandbox', // or 'live' client_id: 'your-client-id', client_secret: 'your-client-secret' });