Spaces:
Running
Running
File size: 4,523 Bytes
4c6b1e8 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 | /* eslint-disable no-console */
const { env } = require("../config/env");
const { connectDB, disconnectDB } = require("../config/db");
const User = require("../models/User");
const Course = require("../models/Course");
const courses = [
{
title: "Artificial Intelligence Essentials",
slug: "artificial-intelligence-essentials",
category: "Artificial Intelligence",
price: 350,
duration: "8 weeks",
level: "Beginner",
description:
"A practical introduction to AI: learn what AI can (and cannot) do, work with real datasets, and build your first machine-learning models.",
highlights: [
"AI concepts, terminology and real-world use cases",
"Hands-on Python & ML experiments",
"Build a simple predictive model end-to-end",
],
},
{
title: "Cyber Security Essentials",
slug: "cyber-security-essentials",
category: "Cyber Security",
price: 300,
duration: "6 weeks",
level: "Beginner",
description:
"Learn the foundations of cyber defense: protect devices, networks, and data against the most common digital threats.",
highlights: [
"Threat landscape and attacker tactics",
"Secure browsing, password & identity hygiene",
"Basic network and endpoint protection",
],
},
{
title: "AI-Powered Cybersecurity",
slug: "ai-powered-cybersecurity",
category: "Cyber Security",
price: 550,
duration: "10 weeks",
level: "Intermediate to Advanced",
description:
"Combine AI with security operations: deploy intelligent threat detection, automate incident response, and build resilient SOC workflows.",
highlights: [
"ML-based threat detection and anomaly analytics",
"Automated incident response playbooks",
"AI governance, ethics and adversarial risks",
],
},
{
title: "The AI Career Guidance",
slug: "the-ai-career-guidance",
category: "Professional Ethics",
price: 200,
duration: "4 weeks",
level: "Career Foundations",
description:
"Map your path into the AI economy. Discover roles, build a portfolio, and prepare for interviews with guided mentorship.",
highlights: [
"AI career landscape and skill roadmap",
"Portfolio project planning and resume review",
"Mock interviews and mentorship sessions",
],
},
{
title: "AI for Business Managers",
slug: "ai-for-business-managers",
category: "Professional Ethics",
price: 450,
duration: "6 weeks",
level: "Manager Level",
description:
"Learn how to evaluate, procure, and manage AI projects that drive real business value without needing to code.",
highlights: [
"AI strategy, ROI and use-case prioritisation",
"Managing data, vendors and project risk",
"Leading AI-enabled teams and change",
],
},
{
title: "AI for Business Executives",
slug: "ai-for-business-executives",
category: "Professional Ethics",
price: 650,
duration: "5 weeks",
level: "Executive Level",
description:
"A leadership-level course on AI governance, competitive strategy, and building an AI-ready organisation.",
highlights: [
"Board-level AI vision and investment decisions",
"Regulatory, ethical and governance frameworks",
"Building an AI culture and Centre of Excellence",
],
},
];
async function seed() {
await connectDB();
for (const c of courses) {
await Course.findOneAndUpdate({ slug: c.slug }, c, { upsert: true, new: true, setDefaultsOnInsert: true });
}
console.log(`Seeded ${courses.length} courses.`);
if (env.seedAdmin.email && env.seedAdmin.password) {
const existingAdmin = await User.findOne({ email: env.seedAdmin.email.toLowerCase() });
if (existingAdmin) {
console.log(`Admin account already exists for ${env.seedAdmin.email}, skipping.`);
} else {
const admin = new User({
name: env.seedAdmin.name,
email: env.seedAdmin.email.toLowerCase(),
role: "admin",
});
await admin.setPassword(env.seedAdmin.password);
await admin.save();
console.log(`Created admin account: ${env.seedAdmin.email}`);
console.log("IMPORTANT: log in and change this password immediately.");
}
} else {
console.log("SEED_ADMIN_EMAIL / SEED_ADMIN_PASSWORD not set — skipping admin creation.");
}
await disconnectDB();
process.exit(0);
}
seed().catch((err) => {
console.error("Seeding failed:", err);
process.exit(1);
});
|