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
N A R R A T I V E
Screen Shot 2020-02-28 at 5.41.22 AM.jpg
contact

Contact us please

  • White Twitter Icon
  • White Facebook Icon
  • White Vimeo Icon
  • White YouTube Icon
  • White Instagram Icon
Join my mailing list

Thanks for submitting!

© 2023 by Daniel Russo. Proudly created with Wix.com

bottom of page