update
This commit is contained in:
1 parent
474235f94d
commit
40e25334fd
3 files changed
+85
-8
No files matched your search
+3
-1
@@ -1,9 +1,11 @@
|
|||||||
{
|
{
|
||||||
|
"student1": [],
|
||||||
"nate": [
|
"nate": [
|
||||||
"Perfect Round",
|
"Perfect Round",
|
||||||
"No Misses",
|
"No Misses",
|
||||||
"Accuracy Master",
|
"Accuracy Master",
|
||||||
"Practice Streak",
|
"Practice Streak",
|
||||||
"Vocabulary Pro"
|
"Vocabulary Pro"
|
||||||
]
|
],
|
||||||
|
"admin1": []
|
||||||
}
|
}
|
||||||
+7
-7
@@ -1,13 +1,13 @@
|
|||||||
{
|
{
|
||||||
"student1": [],
|
"student1": [
|
||||||
|
"apple", "banana", "cherry", "date", "elderberry",
|
||||||
|
"grape", "honeydew", "kiwi", "lemon", "mango"
|
||||||
|
],
|
||||||
"admin1": [
|
"admin1": [
|
||||||
"boy",
|
"administration", "education", "technology", "development", "programming"
|
||||||
"bot",
|
|
||||||
"snot"
|
|
||||||
],
|
],
|
||||||
"nate": [
|
"nate": [
|
||||||
"not",
|
"computer", "keyboard", "mouse", "screen", "printer",
|
||||||
"bot",
|
"software", "hardware", "network", "database", "security"
|
||||||
"snot"
|
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
@@ -30,11 +30,58 @@ function ensureFileWithSeed(name, fallback = '{}') {
|
|||||||
if (fs.existsSync(seedPath)) {
|
if (fs.existsSync(seedPath)) {
|
||||||
fs.copyFileSync(seedPath, targetPath);
|
fs.copyFileSync(seedPath, targetPath);
|
||||||
console.log(`🌱 Seeded ${name} from seed/${name}`);
|
console.log(`🌱 Seeded ${name} from seed/${name}`);
|
||||||
|
} else {
|
||||||
|
// Create default data for each file type
|
||||||
|
if (name === 'users.json') {
|
||||||
|
const defaultUsers = [
|
||||||
|
{
|
||||||
|
"username": "admin1",
|
||||||
|
"hash": "5e884898da28047151d0e56f8dc6292773603d0d6aabbdd62a11ef721d1542d8", // password
|
||||||
|
"role": "admin"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"username": "nate",
|
||||||
|
"hash": "5a2a558c78d3717db731600c4f354fa1d9c84b556f108091a891f444f1bdec40", // nate123
|
||||||
|
"role": "student"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"username": "student1",
|
||||||
|
"hash": "8d969eef6ecad3c29a3a629280e686cf0c3f5d5a86aff3ca12020c923adc6c92", // 123456
|
||||||
|
"role": "student"
|
||||||
|
}
|
||||||
|
];
|
||||||
|
fs.writeFileSync(targetPath, JSON.stringify(defaultUsers, null, 2));
|
||||||
|
console.log(`👥 Created default users: admin1, nate, student1`);
|
||||||
|
} else if (name === 'wordlists.json') {
|
||||||
|
const defaultWordlists = {
|
||||||
|
"student1": [
|
||||||
|
"apple", "banana", "cherry", "date", "elderberry",
|
||||||
|
"grape", "honeydew", "kiwi", "lemon", "mango"
|
||||||
|
],
|
||||||
|
"admin1": [
|
||||||
|
"administration", "education", "technology", "development", "programming"
|
||||||
|
],
|
||||||
|
"nate": [
|
||||||
|
"computer", "keyboard", "mouse", "screen", "printer",
|
||||||
|
"software", "hardware", "network", "database", "security"
|
||||||
|
]
|
||||||
|
};
|
||||||
|
fs.writeFileSync(targetPath, JSON.stringify(defaultWordlists, null, 2));
|
||||||
|
console.log(`📝 Created default word lists for all users`);
|
||||||
|
} else if (name === 'badges.json') {
|
||||||
|
const defaultBadges = {
|
||||||
|
"student1": [],
|
||||||
|
"nate": [],
|
||||||
|
"admin1": []
|
||||||
|
};
|
||||||
|
fs.writeFileSync(targetPath, JSON.stringify(defaultBadges, null, 2));
|
||||||
|
console.log(`🏆 Created default badge structure`);
|
||||||
} else {
|
} else {
|
||||||
fs.writeFileSync(targetPath, fallback);
|
fs.writeFileSync(targetPath, fallback);
|
||||||
console.log(`📄 Initialized ${name} with default`);
|
console.log(`📄 Initialized ${name} with default`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (const [key, file] of Object.entries(files)) {
|
for (const [key, file] of Object.entries(files)) {
|
||||||
@@ -247,4 +294,32 @@ app.get('/getBadges', (req, res) => {
|
|||||||
// 🚀 Server start
|
// 🚀 Server start
|
||||||
app.listen(PORT, () => {
|
app.listen(PORT, () => {
|
||||||
console.log(`✅ Server listening at http://localhost:${PORT}`);
|
console.log(`✅ Server listening at http://localhost:${PORT}`);
|
||||||
|
|
||||||
|
// Display available users for easy login
|
||||||
|
try {
|
||||||
|
const usersPath = path.join(DATA_DIR, files.users);
|
||||||
|
const users = readJsonSafe(usersPath, []);
|
||||||
|
console.log('\n👥 Available Users:');
|
||||||
|
console.log('┌─────────────┬────────────┬──────────┐');
|
||||||
|
console.log('│ Username │ Password │ Role │');
|
||||||
|
console.log('├─────────────┼────────────┼──────────┤');
|
||||||
|
|
||||||
|
const userInfo = [
|
||||||
|
{ username: 'admin1', password: 'password', role: 'admin' },
|
||||||
|
{ username: 'nate', password: 'nate123', role: 'student' },
|
||||||
|
{ username: 'student1', password: '123456', role: 'student' }
|
||||||
|
];
|
||||||
|
|
||||||
|
userInfo.forEach(user => {
|
||||||
|
const exists = users.find(u => u.username === user.username);
|
||||||
|
const status = exists ? '✅' : '❌';
|
||||||
|
console.log(`│ ${user.username.padEnd(11)} │ ${user.password.padEnd(10)} │ ${user.role.padEnd(8)} │ ${status}`);
|
||||||
|
});
|
||||||
|
|
||||||
|
console.log('└─────────────┴────────────┴──────────┘');
|
||||||
|
console.log('\n🔐 Note: Change default passwords after first login!');
|
||||||
|
console.log(`🌐 Access the app at: http://localhost:${PORT}\n`);
|
||||||
|
} catch (error) {
|
||||||
|
console.log('⚠️ Could not display user information');
|
||||||
|
}
|
||||||
});
|
});
|
||||||
Reference in new issue
Block a user