migrated setting routes to typescript

This commit is contained in:
canove
2020-09-15 17:16:29 -03:00
parent 149cbef98e
commit 14d90a2dd4
17 changed files with 111 additions and 34 deletions

View File

@@ -0,0 +1,26 @@
import AppError from "../../errors/AppError";
import Setting from "../../models/Setting";
interface Request {
key: string;
value: string;
}
const UpdateSettingService = async ({
key,
value
}: Request): Promise<Setting | undefined> => {
const setting = await Setting.findOne({
where: { key }
});
if (!setting) {
throw new AppError("No setting found with this ID.", 404);
}
await setting.update({ value });
return setting;
};
export default UpdateSettingService;