feat: bootstrap NestJS backend with auth, stations, users, health-check, now-playing

This commit is contained in:
nk
2026-06-02 13:54:00 +03:00
commit 8aadd62e3c
47 changed files with 13234 additions and 0 deletions

64
prisma/seed.ts Normal file
View File

@@ -0,0 +1,64 @@
import { PrismaClient } from '@prisma/client';
import * as fs from 'fs';
import * as path from 'path';
const prisma = new PrismaClient();
async function main() {
const stationsPath = path.join(__dirname, 'stations.json');
if (!fs.existsSync(stationsPath)) {
console.warn(`Stations file not found at ${stationsPath}. Skipping seed.`);
return;
}
const raw = fs.readFileSync(stationsPath, 'utf-8');
const data = JSON.parse(raw);
const groups: Record<number, string> = {};
for (const group of data.groups || []) {
groups[group.id] = group.name || 'Unknown';
}
const stations = data.stations || [];
console.log(`Seeding ${stations.length} stations...`);
let count = 0;
for (const s of stations) {
const groupName = groups[s.groupId] || 'Unknown';
await prisma.station.upsert({
where: { stationId: s.id },
update: {
name: s.name,
streamUrl: s.stream,
genre: groupName,
tags: [groupName],
sortOrder: count,
source: 'local',
},
create: {
stationId: s.id,
name: s.name,
prefix: '',
streamUrl: s.stream,
coverUrl: null,
genre: groupName,
tags: [groupName],
sortOrder: count,
source: 'local',
},
});
count++;
}
console.log(`Seeded ${count} stations.`);
}
main()
.catch((e) => {
console.error(e);
process.exit(1);
})
.finally(async () => {
await prisma.$disconnect();
});