Files
Zebratic 79d0cfe0a0 Redesign landing page, update pricing plans
- Epic landing page with animated gradient mesh background, bento grid features,
  count-up stats, animated code block, how-it-works section, and columned footer
- New pricing: Pro (9), Max (9, highlighted), Unlimited (9) — no free tier
- Updated seed script with new plans (removes free/enterprise)
- Updated standalone /pricing page to match
- All mobile-first and responsive
2026-03-14 10:03:27 +00:00

178 lines
5.0 KiB
TypeScript

// @ts-nocheck
import "dotenv/config";
import { hash } from "bcryptjs";
import { MongoClient } from "mongodb";
function getDatabaseUrl() {
const url = process.env.DATABASE_URL;
if (!url) throw new Error("Missing DATABASE_URL.");
return url;
}
function getDatabaseNameFromUrl(urlString: string) {
const parsed = new URL(urlString);
const dbName = parsed.pathname.replace("/", "");
return dbName || "test";
}
async function main() {
console.log("Seeding database...");
const databaseUrl = getDatabaseUrl();
const client = new MongoClient(databaseUrl);
await client.connect();
const db = client.db(getDatabaseNameFromUrl(databaseUrl));
try {
const now = new Date();
// Remove legacy free plan
await db.collection("subscription_plans").deleteOne({ name: "free" });
await db.collection("subscription_plans").deleteOne({ name: "enterprise" });
const plans = [
{
name: "pro",
displayName: "Pro",
description: "For developers and small teams",
monthlyPriceCents: 1900,
dailyRequestLimit: null,
dailyTokenLimit: null,
requestLimitPerMonth: 50000,
tokenLimitPerMonth: 10000000,
maxApiKeys: 5,
sortOrder: 0,
isPublic: true,
},
{
name: "max",
displayName: "Max",
description: "For teams shipping to production",
monthlyPriceCents: 4900,
dailyRequestLimit: null,
dailyTokenLimit: null,
requestLimitPerMonth: 200000,
tokenLimitPerMonth: 50000000,
maxApiKeys: 20,
sortOrder: 1,
isPublic: true,
},
{
name: "unlimited",
displayName: "Unlimited",
description: "No limits, full control",
monthlyPriceCents: 9900,
dailyRequestLimit: null,
dailyTokenLimit: null,
requestLimitPerMonth: null,
tokenLimitPerMonth: null,
maxApiKeys: 100,
sortOrder: 2,
isPublic: true,
},
];
for (const plan of plans) {
await db.collection("subscription_plans").updateOne(
{ name: plan.name },
{
$setOnInsert: {
_id: crypto.randomUUID(),
createdAt: now,
},
$set: {
updatedAt: now,
...plan,
},
},
{ upsert: true },
);
}
console.log(" Plans created");
const proPlan = await db.collection<{ _id: string }>("subscription_plans").findOne({ name: "pro" });
if (!proPlan) throw new Error("Pro plan not found after upsert.");
const adminEmail = "[email protected]";
const adminPassword = await hash("admin123", 12);
const existingAdmin = await db.collection<{ _id: string }>("users").findOne({ email: adminEmail });
const adminId = existingAdmin?._id ?? crypto.randomUUID();
await db.collection("users").updateOne(
{ email: adminEmail },
{
$setOnInsert: {
_id: adminId,
email: adminEmail,
passwordHash: adminPassword,
name: "Admin",
role: "ADMIN",
status: "ACTIVE",
createdAt: now,
},
$set: {
updatedAt: now,
},
},
{ upsert: true },
);
await db.collection("subscriptions").updateOne(
{ userId: adminId },
{
$setOnInsert: {
_id: crypto.randomUUID(),
userId: adminId,
planId: proPlan._id,
status: "ACTIVE",
currentPeriodStart: now,
currentPeriodEnd: new Date(Date.now() + 365 * 24 * 60 * 60 * 1000),
createdAt: now,
},
$set: {
updatedAt: now,
},
},
{ upsert: true },
);
console.log(` Admin user created: ${adminEmail} / admin123`);
const providers = [
{ id: "openai", displayName: "OpenAI", baseUrl: "https://api.openai.com" },
{ id: "anthropic", displayName: "Anthropic", baseUrl: "https://api.anthropic.com" },
{ id: "grok", displayName: "Grok (xAI)", baseUrl: "https://api.x.ai" },
{ id: "deepseek", displayName: "DeepSeek", baseUrl: "https://api.deepseek.com" },
{ id: "perplexity", displayName: "Perplexity", baseUrl: "https://api.perplexity.ai" },
{ id: "elevenlabs", displayName: "ElevenLabs", baseUrl: "https://api.elevenlabs.io" },
];
for (const provider of providers) {
await db.collection("providers").updateOne(
{ _id: provider.id },
{
$setOnInsert: { createdAt: now },
$set: {
displayName: provider.displayName,
baseUrl: provider.baseUrl,
enabled: true,
updatedAt: now,
},
},
{ upsert: true },
);
}
console.log(" Providers created");
// Model mappings are auto-discovered during key ingestion via validateApiKey().
console.log("\nSeed complete!");
console.log(" Admin login: [email protected] / admin123");
} finally {
await client.close();
}
}
main().catch((error) => {
console.error(error);
process.exit(1);
});