add user config routes
This commit is contained in:
26
src/userConfig/userConfig.controller.ts
Normal file
26
src/userConfig/userConfig.controller.ts
Normal file
@@ -0,0 +1,26 @@
|
||||
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;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user