27 lines
717 B
TypeScript
27 lines
717 B
TypeScript
import { FastifyReply, FastifyRequest } from "fastify";
|
|
import { getConfig, updateConfig } from "./userConfig.service";
|
|
import { UpdateUserConfigInput } from "./userConfig.schema";
|
|
|
|
export async function getConfigHandler(req: FastifyRequest, res: FastifyReply) {
|
|
try {
|
|
const config = await getConfig(req.user);
|
|
return res.code(200).send(config);
|
|
} catch (err) {
|
|
return err;
|
|
}
|
|
}
|
|
|
|
export async function updateConfigHandler(
|
|
req: FastifyRequest,
|
|
res: FastifyReply
|
|
) {
|
|
const input = req.body as UpdateUserConfigInput;
|
|
console.log(input);
|
|
try {
|
|
const updatedConfig = await updateConfig(input, req.user);
|
|
return res.code(200).send(updatedConfig);
|
|
} catch (err) {
|
|
return err;
|
|
}
|
|
}
|