updated env vars

This commit is contained in:
Omer Sabic 2024-05-30 09:17:59 +02:00
parent a51529042e
commit 2915123f71
5 changed files with 23 additions and 14 deletions

View File

@ -5,3 +5,8 @@ HOST=127.0.0.1
PUBLIC_API_URL=http://localhost:3000 PUBLIC_API_URL=http://localhost:3000
FRONTEND_URL=http://localhost:3002 FRONTEND_URL=http://localhost:3002
SITES_HOST=http://localhost:3001 SITES_HOST=http://localhost:3001
GOOGLE_CLIENT_ID=
GOOGLE_SECRET=
OPENAI_TOKEN=

View File

@ -24,7 +24,7 @@ export const sessions = pgTable("sessions", {
function makeid(length) { function makeid(length) {
let result = ''; let result = '';
const characters = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789'; const characters = 'abcdefghijklmnopqrstuvwxyz';
const charactersLength = characters.length; const charactersLength = characters.length;
let counter = 0; let counter = 0;
while (counter < length) { while (counter < length) {
@ -41,16 +41,16 @@ export const sites = pgTable("sites", {
primary_color_hex: varchar("primary_color_hex", { length: 6 }).default("c4ced4").notNull(), primary_color_hex: varchar("primary_color_hex", { length: 6 }).default("c4ced4").notNull(),
secondary_color_hex: varchar("secondary_color_hex", { length: 6 }).default('27251f').notNull(), secondary_color_hex: varchar("secondary_color_hex", { length: 6 }).default('27251f').notNull(),
text_color_hex: varchar("text_color_hex", { length: 6 }).default('ffffff').notNull(), text_color_hex: varchar("text_color_hex", { length: 6 }).default('ffffff').notNull(),
title: text("title"), title: text("title").default("The best blog in the world!"),
subtitle: text("subtitle"), subtitle: text("subtitle").default("Some extra info about the best blog in the world!"),
domain: text("domain").unique(), domain: text("domain").default("").unique(),
use_freebie: boolean("send_freebie"), use_freebie: boolean("send_freebie").default(""),
freebie_name: text("freebie_name"), freebie_name: text("freebie_name").default(""),
freebie_url: text("freebie_url"), freebie_url: text("freebie_url").default(""),
freebie_text: text("freebie_text"), freebie_text: text("freebie_text").default(""),
freebie_image_url: text("freebie_image_url"), freebie_image_url: text("freebie_image_url").default(""),
subdomain_slug: text("subdomain_slug").$defaultFn(() => { subdomain_slug: text("subdomain_slug").$defaultFn(() => {
return makeid(7); return makeid(10);
}), }),
social_medias: jsonb("social_medias") social_medias: jsonb("social_medias")
}); });

View File

@ -40,8 +40,8 @@ export const main = async () => {
scope: ['https://www.googleapis.com/auth/youtube.readonly', 'https://www.googleapis.com/auth/youtube.force-ssl', "https://www.googleapis.com/auth/userinfo.email", "https://www.googleapis.com/auth/userinfo.profile"], scope: ['https://www.googleapis.com/auth/youtube.readonly', 'https://www.googleapis.com/auth/youtube.force-ssl', "https://www.googleapis.com/auth/userinfo.email", "https://www.googleapis.com/auth/userinfo.profile"],
credentials: { credentials: {
client: { client: {
id: '103003963446-6m80lqbe4bkgjv1nq5ihmju0bb6agkkg.apps.googleusercontent.com', id: env.GOOGLE_CLIENT_ID,
secret: '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' secret: env.GOOGLE_SECRET
}, },
auth: oauth.GOOGLE_CONFIGURATION auth: oauth.GOOGLE_CONFIGURATION
}, },

View File

@ -1,5 +1,6 @@
const defaultModel = '@hf/mistralai/mistral-7b-instruct-v0.2'; const defaultModel = '@hf/mistralai/mistral-7b-instruct-v0.2';
import OpenAI from "openai"; import OpenAI from "openai";
import { env } from "./env";
const openai = new OpenAI({ const openai = new OpenAI({
apiKey: "", apiKey: "",
@ -28,7 +29,7 @@ async function promptGPT(prompt, { model, is_json } = {model: "gpt-3.5-turbo", i
const options = { const options = {
method: 'POST', method: 'POST',
headers: { Authorization: 'Bearer sk-proj-kngnyz8wyoxx4Sw4X4OHT3BlbkFJJBmYAE9odHtYPu1OBEG7', "Content-Type": "application/json" }, headers: { Authorization: `Bearer ${env.OPENAI_TOKEN}`, "Content-Type": "application/json" },
body: JSON.stringify({ body: JSON.stringify({
"model": "gpt-3.5-turbo", "model": "gpt-3.5-turbo",
// "max_tokens": max_tokens, // "max_tokens": max_tokens,

View File

@ -9,6 +9,9 @@ const envSchema = z.object({
PUBLIC_API_URL: z.string(), PUBLIC_API_URL: z.string(),
FRONTEND_URL: z.string(), FRONTEND_URL: z.string(),
SITES_HOST: z.string(), SITES_HOST: z.string(),
GOOGLE_CLIENT_ID: z.string(),
GOOGLE_SECRET: z.string(),
OPENAI_TOKEN: z.string()
}); });
export const env = envSchema.parse(process.env); export const env = envSchema.parse(process.env);