- Created .gitignore to exclude sensitive files and directories. - Added API documentation in API_DOCUMENTATION.md. - Included deployment instructions in DEPLOYMENT.md. - Established project structure documentation in PROJECT_STRUCTURE.md. - Updated README.md with project status and team information. - Added recommendations and status tracking documents. - Introduced testing guidelines in TESTING.md. - Set up CI workflow in .github/workflows/ci.yml. - Created Dockerfile for backend and frontend setups. - Added various service and utility files for backend functionality. - Implemented frontend components and pages for user interface. - Included mobile app structure and services. - Established scripts for deployment across multiple chains.
70 lines
1.6 KiB
TypeScript
70 lines
1.6 KiB
TypeScript
/**
|
|
* Setup script to create initial admin user
|
|
* Run with: npx ts-node scripts/setup-admin.ts
|
|
*/
|
|
|
|
import { PrismaClient } from '@prisma/client';
|
|
import bcrypt from 'bcryptjs';
|
|
import readline from 'readline';
|
|
|
|
const prisma = new PrismaClient();
|
|
|
|
const rl = readline.createInterface({
|
|
input: process.stdin,
|
|
output: process.stdout,
|
|
});
|
|
|
|
function question(query: string): Promise<string> {
|
|
return new Promise((resolve) => {
|
|
rl.question(query, resolve);
|
|
});
|
|
}
|
|
|
|
async function setupAdmin() {
|
|
try {
|
|
console.log('=== ASLE Admin Setup ===\n');
|
|
|
|
const email = await question('Admin email: ');
|
|
const password = await question('Admin password: ');
|
|
const role = await question('Role (admin/super_admin) [admin]: ') || 'admin';
|
|
|
|
// Check if admin already exists
|
|
const existing = await prisma.adminUser.findUnique({
|
|
where: { email },
|
|
});
|
|
|
|
if (existing) {
|
|
console.log('\n❌ Admin user already exists!');
|
|
process.exit(1);
|
|
}
|
|
|
|
// Hash password
|
|
const passwordHash = await bcrypt.hash(password, 10);
|
|
|
|
// Create admin user
|
|
const admin = await prisma.adminUser.create({
|
|
data: {
|
|
email,
|
|
passwordHash,
|
|
role: role as 'admin' | 'super_admin',
|
|
permissions: [],
|
|
active: true,
|
|
},
|
|
});
|
|
|
|
console.log('\n✅ Admin user created successfully!');
|
|
console.log(` ID: ${admin.id}`);
|
|
console.log(` Email: ${admin.email}`);
|
|
console.log(` Role: ${admin.role}`);
|
|
} catch (error: any) {
|
|
console.error('\n❌ Error creating admin user:', error.message);
|
|
process.exit(1);
|
|
} finally {
|
|
rl.close();
|
|
await prisma.$disconnect();
|
|
}
|
|
}
|
|
|
|
setupAdmin();
|
|
|