-
Notifications
You must be signed in to change notification settings - Fork 294
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
change from common js to modules and add initial seeding
- Loading branch information
Showing
19 changed files
with
113 additions
and
41 deletions.
There are no files selected for viewing
File renamed without changes.
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
import { faker } from 'https://esm.sh/@faker-js/faker' | ||
import User from '../User' | ||
import Curriculum from '../Curriculum' | ||
|
||
// Generate seed data for users | ||
const generateUsers = async (numUsers) => { | ||
try { | ||
for (let i = 0; i < numUsers; i++) { | ||
const hashedPassword = await hashPassword(faker.internet.password()) | ||
const user = new User({ | ||
name: faker.name.findName(), | ||
email: faker.internet.email(), | ||
password: hashedPassword, | ||
}) | ||
await user.save() | ||
} | ||
console.log(`${numUsers} users seeded successfully.`) | ||
} catch (error) { | ||
console.error('Error seeding users:', error) | ||
} | ||
} | ||
|
||
// Generate seed data for curricula | ||
// const generateCurricula = async (numCurricula) => { | ||
// try { | ||
// for (let i = 0; i < numCurricula; i++) { | ||
// const curriculum = new Curriculum({ | ||
// title: faker.lorem.words(3), | ||
// description: faker.lorem.sentence(), | ||
// // Add any other curriculum properties you need | ||
// }) | ||
// await curriculum.save() | ||
// } | ||
// console.log(`${numCurricula} curricula seeded successfully.`) | ||
// } catch (error) { | ||
// console.error('Error seeding curricula:', error) | ||
// } | ||
// } | ||
|
||
// Call the functions to generate seed data | ||
const numUsers = 10 // Number of users to generate | ||
// const numCurricula = 5 // Number of curricula to generate | ||
|
||
generateUsers(numUsers) | ||
// generateCurricula(numCurricula) |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
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
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,5 +1,9 @@ | ||
module.exports = { | ||
auth: require('./auth'), | ||
jwt: require('./jwt'), | ||
mailgun: require('./mailgun') | ||
import auth from './auth' | ||
import jwt from './jwt' | ||
import mailgun from './mailgun' | ||
|
||
export default { | ||
auth, | ||
jwt, | ||
mailgun | ||
} |
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,4 +1,4 @@ | ||
var jwt = require('jsonwebtoken') | ||
import jwt from 'jsonwebtoken' | ||
|
||
const secret = 'gwenstacy' | ||
const header = { | ||
|
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