From 89f44aad7dc78c175997b47ac98d396169221d7a Mon Sep 17 00:00:00 2001 From: Omer Sabic Date: Fri, 7 Jun 2024 17:18:44 +0200 Subject: [PATCH] fixes --- src/db/schemas.js | 2 +- src/routes/auth.js | 3 +++ src/utils/youtube.js | 3 +++ 3 files changed, 7 insertions(+), 1 deletion(-) diff --git a/src/db/schemas.js b/src/db/schemas.js index 5af4791..859c28d 100644 --- a/src/db/schemas.js +++ b/src/db/schemas.js @@ -44,7 +44,7 @@ export const sites = pgTable("sites", { text_color_hex: varchar("text_color_hex", { length: 6 }).default('ffffff').notNull(), title: text("title").default("The best blog in the world!"), subtitle: text("subtitle").default("Some extra info about the best blog in the world!"), - domain: text("domain").default(null), + domain: text("domain").$default(null), use_freebie: boolean("send_freebie").default(false), freebie_name: text("freebie_name").default(""), freebie_url: text("freebie_url").default(""), diff --git a/src/routes/auth.js b/src/routes/auth.js index 980d6fc..1a11bcd 100644 --- a/src/routes/auth.js +++ b/src/routes/auth.js @@ -105,6 +105,9 @@ export const authRoutes = (fastify, _, done) => { // }); return; } catch (e) { + if(e.message === "no_channel") { + response.status(400).send("Your account does not have a youtube channel. Please make one.") + } console.log(e); response.send({ success: false, message: e.message }); return; diff --git a/src/utils/youtube.js b/src/utils/youtube.js index 97f3e7c..807c503 100644 --- a/src/utils/youtube.js +++ b/src/utils/youtube.js @@ -98,6 +98,9 @@ export async function getChannelInfo(access_token) { maxResults: 1 }).then(res => res); + if(!channel.data.items[0]) { + throw new Error("no_channel"); + } return channel.data.items[0]; }