Start implementation of branches, new form element tabledropdown, model improvements
This commit is contained in:
@@ -1,13 +1,69 @@
|
||||
import * as falukantService from '../services/falukantService.js';
|
||||
import FalukantService from '../services/falukantService.js';
|
||||
|
||||
class FalukantController {
|
||||
constructor() {
|
||||
this.exampleMethod = this.exampleMethod.bind(this);
|
||||
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 exampleMethod(req, res) {
|
||||
async getUser(req, res) {
|
||||
try {
|
||||
const result = await falukantService.exampleMethod();
|
||||
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 });
|
||||
|
||||
Reference in New Issue
Block a user