bds
This commit is contained in:
parent
00fb06aaad
commit
933db8828b
2
src/db/migrations/0007_familiar_thor_girl.sql
Normal file
2
src/db/migrations/0007_familiar_thor_girl.sql
Normal file
@ -0,0 +1,2 @@
|
||||
ALTER TABLE "articles" ADD COLUMN "title" text;--> statement-breakpoint
|
||||
ALTER TABLE "articles" ADD COLUMN "seo_slug" text;
|
221
src/db/migrations/meta/0007_snapshot.json
Normal file
221
src/db/migrations/meta/0007_snapshot.json
Normal file
@ -0,0 +1,221 @@
|
||||
{
|
||||
"id": "10737e50-695f-41a3-94b4-e34439850a06",
|
||||
"prevId": "3ec0762e-c27b-4b7f-b4a6-4db07400a5ae",
|
||||
"version": "5",
|
||||
"dialect": "pg",
|
||||
"tables": {
|
||||
"articles": {
|
||||
"name": "articles",
|
||||
"schema": "",
|
||||
"columns": {
|
||||
"id": {
|
||||
"name": "id",
|
||||
"type": "uuid",
|
||||
"primaryKey": true,
|
||||
"notNull": true,
|
||||
"default": "gen_random_uuid()"
|
||||
},
|
||||
"site_id": {
|
||||
"name": "site_id",
|
||||
"type": "uuid",
|
||||
"primaryKey": false,
|
||||
"notNull": false
|
||||
},
|
||||
"content": {
|
||||
"name": "content",
|
||||
"type": "text",
|
||||
"primaryKey": false,
|
||||
"notNull": false
|
||||
},
|
||||
"source_video_id": {
|
||||
"name": "source_video_id",
|
||||
"type": "text",
|
||||
"primaryKey": false,
|
||||
"notNull": false
|
||||
},
|
||||
"title": {
|
||||
"name": "title",
|
||||
"type": "text",
|
||||
"primaryKey": false,
|
||||
"notNull": false
|
||||
},
|
||||
"seo_slug": {
|
||||
"name": "seo_slug",
|
||||
"type": "text",
|
||||
"primaryKey": false,
|
||||
"notNull": false
|
||||
}
|
||||
},
|
||||
"indexes": {},
|
||||
"foreignKeys": {
|
||||
"articles_site_id_sites_id_fk": {
|
||||
"name": "articles_site_id_sites_id_fk",
|
||||
"tableFrom": "articles",
|
||||
"tableTo": "sites",
|
||||
"columnsFrom": [
|
||||
"site_id"
|
||||
],
|
||||
"columnsTo": [
|
||||
"id"
|
||||
],
|
||||
"onDelete": "no action",
|
||||
"onUpdate": "no action"
|
||||
}
|
||||
},
|
||||
"compositePrimaryKeys": {},
|
||||
"uniqueConstraints": {}
|
||||
},
|
||||
"sessions": {
|
||||
"name": "sessions",
|
||||
"schema": "",
|
||||
"columns": {
|
||||
"id": {
|
||||
"name": "id",
|
||||
"type": "uuid",
|
||||
"primaryKey": true,
|
||||
"notNull": true,
|
||||
"default": "gen_random_uuid()"
|
||||
},
|
||||
"user_id": {
|
||||
"name": "user_id",
|
||||
"type": "uuid",
|
||||
"primaryKey": false,
|
||||
"notNull": false
|
||||
},
|
||||
"google_access_token": {
|
||||
"name": "google_access_token",
|
||||
"type": "text",
|
||||
"primaryKey": false,
|
||||
"notNull": false
|
||||
},
|
||||
"google_refresh_token": {
|
||||
"name": "google_refresh_token",
|
||||
"type": "text",
|
||||
"primaryKey": false,
|
||||
"notNull": false
|
||||
},
|
||||
"expires_at": {
|
||||
"name": "expires_at",
|
||||
"type": "timestamp",
|
||||
"primaryKey": false,
|
||||
"notNull": false
|
||||
}
|
||||
},
|
||||
"indexes": {},
|
||||
"foreignKeys": {
|
||||
"sessions_user_id_users_id_fk": {
|
||||
"name": "sessions_user_id_users_id_fk",
|
||||
"tableFrom": "sessions",
|
||||
"tableTo": "users",
|
||||
"columnsFrom": [
|
||||
"user_id"
|
||||
],
|
||||
"columnsTo": [
|
||||
"id"
|
||||
],
|
||||
"onDelete": "no action",
|
||||
"onUpdate": "no action"
|
||||
}
|
||||
},
|
||||
"compositePrimaryKeys": {},
|
||||
"uniqueConstraints": {}
|
||||
},
|
||||
"sites": {
|
||||
"name": "sites",
|
||||
"schema": "",
|
||||
"columns": {
|
||||
"id": {
|
||||
"name": "id",
|
||||
"type": "uuid",
|
||||
"primaryKey": true,
|
||||
"notNull": true,
|
||||
"default": "gen_random_uuid()"
|
||||
},
|
||||
"user_id": {
|
||||
"name": "user_id",
|
||||
"type": "uuid",
|
||||
"primaryKey": false,
|
||||
"notNull": false
|
||||
},
|
||||
"name": {
|
||||
"name": "name",
|
||||
"type": "text",
|
||||
"primaryKey": false,
|
||||
"notNull": false
|
||||
}
|
||||
},
|
||||
"indexes": {},
|
||||
"foreignKeys": {
|
||||
"sites_user_id_users_id_fk": {
|
||||
"name": "sites_user_id_users_id_fk",
|
||||
"tableFrom": "sites",
|
||||
"tableTo": "users",
|
||||
"columnsFrom": [
|
||||
"user_id"
|
||||
],
|
||||
"columnsTo": [
|
||||
"id"
|
||||
],
|
||||
"onDelete": "no action",
|
||||
"onUpdate": "no action"
|
||||
}
|
||||
},
|
||||
"compositePrimaryKeys": {},
|
||||
"uniqueConstraints": {}
|
||||
},
|
||||
"users": {
|
||||
"name": "users",
|
||||
"schema": "",
|
||||
"columns": {
|
||||
"id": {
|
||||
"name": "id",
|
||||
"type": "uuid",
|
||||
"primaryKey": true,
|
||||
"notNull": true,
|
||||
"default": "gen_random_uuid()"
|
||||
},
|
||||
"google_id": {
|
||||
"name": "google_id",
|
||||
"type": "text",
|
||||
"primaryKey": false,
|
||||
"notNull": false
|
||||
},
|
||||
"name": {
|
||||
"name": "name",
|
||||
"type": "text",
|
||||
"primaryKey": false,
|
||||
"notNull": false
|
||||
},
|
||||
"email": {
|
||||
"name": "email",
|
||||
"type": "text",
|
||||
"primaryKey": false,
|
||||
"notNull": false
|
||||
},
|
||||
"channel_id": {
|
||||
"name": "channel_id",
|
||||
"type": "text",
|
||||
"primaryKey": false,
|
||||
"notNull": false
|
||||
},
|
||||
"uploads_playlist_id": {
|
||||
"name": "uploads_playlist_id",
|
||||
"type": "text",
|
||||
"primaryKey": false,
|
||||
"notNull": false
|
||||
}
|
||||
},
|
||||
"indexes": {},
|
||||
"foreignKeys": {},
|
||||
"compositePrimaryKeys": {},
|
||||
"uniqueConstraints": {}
|
||||
}
|
||||
},
|
||||
"enums": {},
|
||||
"schemas": {},
|
||||
"_meta": {
|
||||
"schemas": {},
|
||||
"tables": {},
|
||||
"columns": {}
|
||||
}
|
||||
}
|
@ -50,6 +50,13 @@
|
||||
"when": 1713614011867,
|
||||
"tag": "0006_wide_the_hunter",
|
||||
"breakpoints": true
|
||||
},
|
||||
{
|
||||
"idx": 7,
|
||||
"version": "5",
|
||||
"when": 1714378789934,
|
||||
"tag": "0007_familiar_thor_girl",
|
||||
"breakpoints": true
|
||||
}
|
||||
]
|
||||
}
|
@ -25,7 +25,9 @@ export const sites = pgTable("sites", {
|
||||
|
||||
export const articles = pgTable("articles", {
|
||||
id: uuid("id").defaultRandom().primaryKey(),
|
||||
site_id: uuid("site_id").references(() => site.id),
|
||||
site_id: uuid("site_id").references(() => sites.id),
|
||||
content: text("content"),
|
||||
source_video_id: text("source_video_id")
|
||||
source_video_id: text("source_video_id"),
|
||||
title: text("title"),
|
||||
seo_slug: text("seo_slug")
|
||||
})
|
@ -1,7 +1,7 @@
|
||||
import { createSession as createSession } from '../utils/token.js';
|
||||
import { getChannelInfo, getUserInfo } from '../utils/youtube.js';
|
||||
import { db } from '../db/index.js';
|
||||
import { users as usersTable } from '../db/schemas.js';
|
||||
import { sessions, users, users as usersTable } from '../db/schemas.js';
|
||||
import { eq } from 'drizzle-orm';
|
||||
import { env } from '../utils/env.js';
|
||||
import { authMiddleware, authMiddlewareFn } from '../modules/middleware.js';
|
||||
@ -56,7 +56,12 @@ export const authRoutes = (fastify, _, done) => {
|
||||
session_id = session_info.session_id;
|
||||
}
|
||||
else {
|
||||
console.error("ERROR: NOT IMPLEMENTED")
|
||||
let session_info = await db.select().from(users).leftJoin(sessions, eq(sessions.user_id, users.id)).where(eq(users.google_id, user_info.id));
|
||||
if(session_info.length == 0) {
|
||||
response.status(400).send({ success: false, message: "Problem when creating user account" });
|
||||
return;
|
||||
}
|
||||
session_id = session_info[0].sessions.id
|
||||
}
|
||||
|
||||
// response.setCookie("token", session_id, {
|
||||
|
@ -76,11 +76,11 @@ export const blogRoutes = (fastify, _, done) => {
|
||||
|
||||
const caption_body = await getCaptionText(access_token, preferred_caption_id);
|
||||
const caption_text = parseTextFromCaptions(caption_body).substring(28);
|
||||
console.log(caption_text);
|
||||
|
||||
const blog_content = await createBlogFromCaptions(caption_text, req.body);
|
||||
// TODO: once I add multiple sites per user, this should come from the client
|
||||
const site = await db.select().from(sites).where(eq(sites.user_id, req.session.user_id));
|
||||
console.log(site)
|
||||
|
||||
const article = await db.insert(articlesTable).values({
|
||||
site_id: site[0].id,
|
||||
|
@ -62,9 +62,9 @@ export async function createBlogFromCaptions(captions, {
|
||||
format,
|
||||
tone
|
||||
} = {length: 500, language: "English", format: "summary", tone: "informal"}) {
|
||||
const prompt = `Please convert the following video transcript into a blog post. The approximate length should be around ${length || 500} characters, written in ${language || "English"}. The desired format of the blog post is a ${format || "summary"}. Please ensure the blog post has a ${tone || "informal"} tone throughout. Use markdown to format the article. Here is the transcript: `
|
||||
const prompt = `Please convert the following video transcript into a blog post. The approximate length should be around ${length || 500} characters, written in ${language || "English"}. The desired format of the blog post is a ${format || "summary"}. Please ensure the blog post has a ${tone || "informal"} tone throughout. Use markdown to format the article. You must always respond in the following json fromat: {"title": string, "content": string, "seo_friendly_slug": string}. \nHere is the transcript: `
|
||||
|
||||
const result = await promptGPT(prompt + captions);
|
||||
|
||||
console.log(result);
|
||||
return result;
|
||||
}
|
Loading…
Reference in New Issue
Block a user