adds user accounts, service requests, dashboard, admin panel, better layout, db+altcha+auth support
This commit is contained in:
parent
dfbc3cade9
commit
0043a5bf3c
40 changed files with 3981 additions and 188 deletions
22
tools/hmac.ts
Normal file
22
tools/hmac.ts
Normal file
|
@ -0,0 +1,22 @@
|
|||
import crypto from 'crypto'
|
||||
import fs from 'fs'
|
||||
|
||||
const hmacKey = crypto.randomBytes(32).toString('hex')
|
||||
|
||||
if (fs.existsSync('.env.local')) {
|
||||
const envFile = fs.readFileSync('.env.local', 'utf8')
|
||||
// Double-check it's not already set
|
||||
if (!envFile.includes('ALTCHA_SECRET')) {
|
||||
fs.appendFileSync('.env.local', `\nALTCHA_SECRET=${hmacKey}`)
|
||||
}
|
||||
console.log(`Successfully wrote ALTCHA_SECRET to .env.local`)
|
||||
} else if (fs.existsSync('.env')) {
|
||||
const envFile = fs.readFileSync('.env', 'utf8')
|
||||
// Double-check it's not already set
|
||||
if (!envFile.includes('ALTCHA_SECRET')) {
|
||||
fs.appendFileSync('.env', `\nALTCHA_SECRET=${hmacKey}`)
|
||||
}
|
||||
console.log(`Successfully wrote ALTCHA_SECRET to .env`)
|
||||
} else {
|
||||
console.error('No .env/.env.local file found, please create one first.')
|
||||
}
|
28
tools/seed-db.ts
Normal file
28
tools/seed-db.ts
Normal file
|
@ -0,0 +1,28 @@
|
|||
import { db } from "../db";
|
||||
import { services } from "../db/schema";
|
||||
import { services as serviceConfig } from "../config/services";
|
||||
import { nanoid } from "nanoid";
|
||||
|
||||
async function seedDatabase() {
|
||||
try {
|
||||
console.log("Seeding database...");
|
||||
await db.delete(services);
|
||||
for (const service of serviceConfig) {
|
||||
await db.insert(services).values({
|
||||
id: nanoid(),
|
||||
name: service.name,
|
||||
description: service.description,
|
||||
priceStatus: service.priceStatus,
|
||||
joinLink: service.joinLink || null,
|
||||
enabled: true
|
||||
});
|
||||
console.log(`✓ Added service: ${service.name}`);
|
||||
}
|
||||
console.log("Database seeded!");
|
||||
} catch (error) {
|
||||
console.error("Error seeding database:", error);
|
||||
process.exit(1);
|
||||
}
|
||||
}
|
||||
|
||||
seedDatabase();
|
Loading…
Add table
Add a link
Reference in a new issue