const express = require('express');
const jwt = require('jsonwebtoken');
const bcrypt = require('bcrypt');
const User = require('./models/User'); // Your user model
const app = express();
app.use(express.json());
// User registration
app.post('/register', async (req, res) => {
const { email, password } = req.body;
const hashedPassword = await bcrypt.hash(password, 10);
const user = new User({ email, password: hashedPassword });
await user.save();
const token = jwt.sign({ userId: user._id }, 'secretKey');
res.json({ token });
});
// User login
app.post('/login', async (req, res) => {
const { email, password } = req.body;
const user = await User.findOne({ email });
if (user && await bcrypt.compare(password, user.password)) {
const token = jwt.sign({ userId: user._id }, 'secretKey');
res.json({ token });
} else {
res.status(400).json({ message: 'Invalid credentials' });
}
});
// More routes for profile handling, messaging, etc.
app.listen(3000, () => {
console.log('Server running on port 3000');
});
H O M E | Only Orphans Dating
const express = require('express');
const jwt = require('jsonwebtoken');
const bcrypt = require('bcrypt');
const User = require('./models/User'); // Your user model
const app = express();
app.use(express.json());
// User registration
app.post('/register', async (req, res) => {
const { email, password } = req.body;
const hashedPassword = await bcrypt.hash(password, 10);
const user = new User({ email, password: hashedPassword });
await user.save();
const token = jwt.sign({ userId: user._id }, 'secretKey');
res.json({ token });
});
// User login
app.post('/login', async (req, res) => {
const { email, password } = req.body;
const user = await User.findOne({ email });
if (user && await bcrypt.compare(password, user.password)) {
const token = jwt.sign({ userId: user._id }, 'secretKey');
res.json({ token });
} else {
res.status(400).json({ message: 'Invalid credentials' });
}
});
// More routes for profile handling, messaging, etc.
app.listen(3000, () => {
console.log('Server running on port 3000');
});
top of page
Only Orphans is....
An online community to help orphans find luck in the dating world. Weather you're looking for the love of another orphan, or you simply want to date someone without annoying in-laws, Only Orphans is for you.