Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TrendFinder UI (In progress) #20

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
140 changes: 131 additions & 9 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 8 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,30 +5,35 @@
"scripts": {
"start": "nodemon src/index.ts",
"build": "tsc",
"test": "echo \"Error: no test specified\" && exit 1"
"test": "echo \"Error: no test specified\" && exit 1",
"api": "ts-node src/api/index.ts"
},
"author": "",
"license": "ISC",
"devDependencies": {
"@types/cors": "^2.8.17",
"@types/express": "^4.17.21",
"@types/node": "^20.10.2",
"@types/node-cron": "^3.0.11",
"nodemon": "^3.0.2",
"pre-commit": "^1.2.2",
"rimraf": "^5.0.5",
"ts-node": "^10.9.1",
"ts-node": "^10.9.2",
"typescript": "^5.3.2"
},
"dependencies": {
"@mendable/firecrawl-js": "^1.8.1",
"@prisma/client": "^6.1.0",
"@supabase/supabase-js": "^2.46.1",
"cors": "^2.8.5",
"dotenv": "^14.3.2",
"express": "^4.18.2",
"express": "^4.21.2",
"express-async-handler": "^1.2.0",
"firecrawl": "^1.7.2",
"node-cron": "^3.0.3",
"openai": "^4.72.0",
"playht": "^0.13.0",
"prisma": "^6.1.0",
"resend": "^4.0.1-alpha.0",
"together-ai": "^0.9.0",
"ts-node-dev": "^2.0.0"
Expand Down
Binary file added prisma/dev.db
Binary file not shown.
32 changes: 32 additions & 0 deletions prisma/migrations/20250105025622_separate_x_accounts/migration.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
-- CreateTable
CREATE TABLE "Settings" (
"id" INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
"cronInterval" INTEGER NOT NULL DEFAULT 15,
"createdAt" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
"updatedAt" DATETIME NOT NULL
);

-- CreateTable
CREATE TABLE "XAccount" (
"id" INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
"username" TEXT NOT NULL,
"createdAt" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
"updatedAt" DATETIME NOT NULL
);

-- CreateTable
CREATE TABLE "ApiKeys" (
"id" INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
"service" TEXT NOT NULL,
"key" TEXT NOT NULL,
"createdAt" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
"updatedAt" DATETIME NOT NULL
);

-- CreateTable
CREATE TABLE "RunHistory" (
"id" INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
"status" TEXT NOT NULL,
"message" TEXT,
"createdAt" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP
);
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
/*
Warnings:

- A unique constraint covering the columns `[service]` on the table `ApiKeys` will be added. If there are existing duplicate values, this will fail.

*/
-- CreateIndex
CREATE UNIQUE INDEX "ApiKeys_service_key" ON "ApiKeys"("service");
3 changes: 3 additions & 0 deletions prisma/migrations/migration_lock.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Please do not edit this file manually
# It should be added in your version-control system (e.g., Git)
provider = "sqlite"
37 changes: 37 additions & 0 deletions prisma/schema.prisma
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
generator client {
provider = "prisma-client-js"
}

datasource db {
provider = "sqlite"
url = "file:./dev.db"
}

model Settings {
id Int @id @default(autoincrement())
cronInterval Int @default(15) // in minutes
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
}

model XAccount {
id Int @id @default(autoincrement())
username String // Store each X account as a separate record
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
}

model ApiKeys {
id Int @id @default(autoincrement())
service String @unique
key String
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
}

model RunHistory {
id Int @id @default(autoincrement())
status String // "success" | "error"
message String?
createdAt DateTime @default(now())
}
25 changes: 25 additions & 0 deletions src/api/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import express from 'express'
import cors from 'cors'
import { handleCron } from '../controllers/cron'
import configRouter from '../routes/config'

const app = express()
app.use(cors())
app.use(express.json())

// Mount config routes
app.use('/api', configRouter)

// Original cron endpoint
app.post('/api/cron', async (req, res) => {
try {
await handleCron()
res.json({ success: true })
} catch (error) {
res.status(500).json({ error: 'Failed to run cron' })
}
})

app.listen(3001, () => {
console.log('API server running on port 3001')
})
Loading