-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #56 from codeurjc-students/refactor-code-cleanup-a…
…nd-format Refactor code cleanup and format
- Loading branch information
Showing
76 changed files
with
1,660 additions
and
2,042 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,4 +16,4 @@ const dropDatabase = async () => { | |
} | ||
}; | ||
|
||
module.exports = dropDatabase; | ||
module.exports = dropDatabase; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,50 +1,48 @@ | ||
const mongoose = require('mongoose'); | ||
const User = require('../models/user.model'); | ||
const bcrypt = require('bcrypt'); | ||
const mongoose = require("mongoose"); | ||
const User = require("../models/user.model"); | ||
const bcrypt = require("bcrypt"); | ||
|
||
const seedAdmins = async () => { | ||
try { | ||
const admins = [ | ||
{ | ||
username: 'admin_one', | ||
password: 'admin123', | ||
email: '[email protected]', | ||
firstName: 'Admin', | ||
lastName: 'One', | ||
bio: 'Administrador principal.', | ||
role: 'admin', | ||
username: "admin_one", | ||
password: "admin123", | ||
email: "[email protected]", | ||
firstName: "Admin", | ||
lastName: "One", | ||
bio: "Administrador principal.", | ||
role: "admin", | ||
isVerified: true, | ||
verificationToken: null, | ||
}, | ||
{ | ||
username: 'admin_two', | ||
password: 'admin123', | ||
email: '[email protected]', | ||
firstName: 'Admin', | ||
lastName: 'Two', | ||
bio: 'Administrador secundario.', | ||
role: 'admin', | ||
username: "admin_two", | ||
password: "admin123", | ||
email: "[email protected]", | ||
firstName: "Admin", | ||
lastName: "Two", | ||
bio: "Administrador secundario.", | ||
role: "admin", | ||
isVerified: true, | ||
verificationToken: null, | ||
}, | ||
]; | ||
|
||
for (const adminData of admins) { | ||
const exist = await User.findOne({ email: adminData.email }); | ||
if (!exist) { | ||
const salt = await bcrypt.genSalt(10); | ||
const hashedPassword = await bcrypt.hash(adminData.password, salt); | ||
adminData.password = hashedPassword; | ||
|
||
await User.create(adminData); | ||
console.log(`Admin created: ${adminData.email}`); | ||
} else { | ||
console.log(`Admin ${adminData.email} already exists`); | ||
} | ||
} | ||
console.log('Admins seeded successfully'); | ||
console.log("Admins seeded successfully"); | ||
} catch (error) { | ||
console.error('Error seeding admins:', error); | ||
console.error("Error seeding admins:", error); | ||
process.exit(1); | ||
} | ||
}; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.