const express = require('express') const app = express() const port = 50429 const data = [{ name: "Test", password: "12345" }] app.get('/api/auth/login', (req, res) => { // let { name, password } = req.body; let name = "Test" let password = "12345" if (!name || !password) return req.json({ "status": "error", "message": "Lütfen geçerli parametreleri giriniz." }) let userData = data.find(x => x.name === name && x.password === password) if (!userData) req.json({ "status": "error", "message": "Bir kullanıcı bulunamadı!" }) userData.key = randomAutKey() res.json({ "status": "success", "message": "Giriş başarılı!", "data": userData }) }) app.listen(port, () => { console.log(`Example app listening on port ${port}`) }) function randomAutKey() { let result = ''; const characters = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789'; const charactersLength = characters.length; let counter = 0; while (counter < 40) { result += characters.charAt(Math.floor(Math.random() * charactersLength)); counter += 1; } return result; }