mirror of
https://github.com/Sendouc/sendou.ink.git
synced 2026-08-12 20:40:47 -05:00
Zod validated config for security and ease of getting started
This commit is contained in:
@@ -1,25 +1,12 @@
|
||||
import fs from "node:fs";
|
||||
import { seed } from "~/db/seed";
|
||||
import { db } from "~/db/sql";
|
||||
import { logger } from "~/utils/logger";
|
||||
import { seedImages } from "./seed-images";
|
||||
|
||||
async function main() {
|
||||
// Step 1: Create .env if it doesn't exist
|
||||
if (!fs.existsSync(".env")) {
|
||||
logger.info("📄 .env not found. Creating from .env.example...");
|
||||
const envContent = fs.readFileSync(".env.example", "utf-8");
|
||||
const filteredEnv = envContent
|
||||
.split("\n")
|
||||
.filter((line) => !line.trim().startsWith("//")) // remove comments to prevent issues with Docker
|
||||
.join("\n");
|
||||
fs.writeFileSync(".env", filteredEnv);
|
||||
logger.info(".env created with default values");
|
||||
}
|
||||
|
||||
const dbEmpty = !(await db.selectFrom("User").selectAll().executeTakeFirst());
|
||||
|
||||
// Step 2: Run migration and seed if db.sqlite3 doesn't exist
|
||||
// Run migration and seed if db.sqlite3 doesn't exist
|
||||
if (dbEmpty) {
|
||||
logger.info("🌱 Seeding database...");
|
||||
try {
|
||||
@@ -34,7 +21,7 @@ async function main() {
|
||||
}
|
||||
}
|
||||
|
||||
// Step 3: Seed images to Minio
|
||||
// Seed images to Minio
|
||||
logger.info("🖼️ Seeding images to Minio...");
|
||||
try {
|
||||
await seedImages();
|
||||
|
||||
Reference in New Issue
Block a user