Initial commit: Expedição Gold SaaS

This commit is contained in:
Carlos
2026-06-25 00:55:34 +02:00
commit 1bf21f0754
13 changed files with 1356 additions and 0 deletions
+32
View File
@@ -0,0 +1,32 @@
import { hashSync, compareSync } from 'bcryptjs';
import { v4 as uuidv4 } from 'uuid';
// In-memory store for demo purposes
let users = [];
export default function handler(req, res) {
if (req.method !== 'POST') {
return res.status(405).json({ message: 'Method not allowed' });
}
const { username, password } = req.body;
if (!username || !password) {
return res.status(400).json({ message: 'Username and password required' });
}
// Check if user exists
const existing = users.find(u => u.username === username);
if (existing) {
return res.status(400).json({ message: 'User already exists' });
}
const id = uuidv4();
const hashedPassword = hashSync(password, 10);
users.push({ id, username, password: hashedPassword });
// Return a fake JWT token (just a string)
const token = `${id}:${Date.now()}`;
res.status(201).json({ token, user: { id, username } });
}