import FalukantService from '../services/falukantService.js'; class FalukantController { constructor() { this.getUser = this.getUser.bind(this); this.createUser = this.createUser.bind(this); this.randomFirstName = this.randomFirstName.bind(this); this.randomLastName = this.randomLastName.bind(this); this.getInfo = this.getInfo.bind(this); } async getUser(req, res) { try { const { userid: hashedUserId } = req.headers; const result = await FalukantService.getUser(hashedUserId); res.status(200).json(result); } catch (error) { res.status(500).json({ error: error.message }); } } async createUser(req, res) { try { const { userid: hashedUserId } = req.headers; const { gender, firstname: firstName, lastname: lastName } = req.body; console.log(req.body); const result = await FalukantService.createUser(hashedUserId, gender, firstName, lastName); res.status(201).json(result); } catch (error) { res.status(500).json({ error: error.message }); } } async randomFirstName(req, res) { try { const { gender } = req.params; const result = await FalukantService.randomFirstName(gender); res.status(200).json({ name: result }); } catch (error) { res.status(500).json({ error: error.message }); } } async randomLastName(req, res) { try { const result = await FalukantService.randomLastName(); res.status(200).json({ name: result }); } catch (error) { res.status(500).json({ error: error.message }); } } async getInfo(req, res) { try { const { userid: hashedUserId } = req.headers; const result = await FalukantService.getInfo(hashedUserId); res.status(200).json(result); } catch (error) { res.status(500).json({ error: error.message }); } } async getBranches(req, res) { try { const { userid: hashedUserId } = req.headers; const result = await FalukantService.getBranches(hashedUserId); res.status(200).json(result); } catch (error) { res.status(500).json({ error: error.message }); } } } export default FalukantController;