mirror of
https://github.com/ets-cfuhrman-pfe/EvalueTonSavoir.git
synced 2025-08-11 21:23:54 -04:00
order of instantiation in app.js, user needs folder model
This commit is contained in:
parent
0fe07b84c6
commit
89a5146afe
4 changed files with 5 additions and 10 deletions
|
|
@ -10,12 +10,12 @@ const { Server } = require("socket.io");
|
||||||
// instantiate the db
|
// instantiate the db
|
||||||
const db = require('./config/db.js');
|
const db = require('./config/db.js');
|
||||||
// instantiate the models
|
// instantiate the models
|
||||||
const users = require('./models/users.js');
|
|
||||||
const userModel = new users(db);
|
|
||||||
const quiz = require('./models/quiz.js');
|
const quiz = require('./models/quiz.js');
|
||||||
const quizModel = new quiz(db);
|
const quizModel = new quiz(db);
|
||||||
const folders = require('./models/folders.js');
|
const folders = require('./models/folders.js');
|
||||||
const foldersModel = new folders(db, quizModel);
|
const foldersModel = new folders(db, quizModel);
|
||||||
|
const users = require('./models/users.js');
|
||||||
|
const userModel = new users(db, foldersModel);
|
||||||
const images = require('./models/images.js');
|
const images = require('./models/images.js');
|
||||||
const imageModel = new images(db);
|
const imageModel = new images(db);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,3 @@
|
||||||
const model = require('../models/images.js');
|
|
||||||
|
|
||||||
const AppError = require('../middleware/AppError.js');
|
const AppError = require('../middleware/AppError.js');
|
||||||
const { MISSING_REQUIRED_PARAMETER, IMAGE_NOT_FOUND } = require('../constants/errorCodes');
|
const { MISSING_REQUIRED_PARAMETER, IMAGE_NOT_FOUND } = require('../constants/errorCodes');
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,4 @@
|
||||||
// const model = require('../models/quiz.js');
|
|
||||||
const emailer = require('../config/email.js');
|
const emailer = require('../config/email.js');
|
||||||
//const foldersController = require('./folders.js');
|
|
||||||
// const db = require('../config/db.js');
|
|
||||||
|
|
||||||
const AppError = require('../middleware/AppError.js');
|
const AppError = require('../middleware/AppError.js');
|
||||||
const { MISSING_REQUIRED_PARAMETER, NOT_IMPLEMENTED, QUIZ_NOT_FOUND, FOLDER_NOT_FOUND, QUIZ_ALREADY_EXISTS, GETTING_QUIZ_ERROR, DELETE_QUIZ_ERROR, UPDATE_QUIZ_ERROR, MOVING_QUIZ_ERROR, DUPLICATE_QUIZ_ERROR, COPY_QUIZ_ERROR } = require('../constants/errorCodes');
|
const { MISSING_REQUIRED_PARAMETER, NOT_IMPLEMENTED, QUIZ_NOT_FOUND, FOLDER_NOT_FOUND, QUIZ_ALREADY_EXISTS, GETTING_QUIZ_ERROR, DELETE_QUIZ_ERROR, UPDATE_QUIZ_ERROR, MOVING_QUIZ_ERROR, DUPLICATE_QUIZ_ERROR, COPY_QUIZ_ERROR } = require('../constants/errorCodes');
|
||||||
|
|
|
||||||
|
|
@ -2,12 +2,12 @@
|
||||||
const bcrypt = require('bcrypt');
|
const bcrypt = require('bcrypt');
|
||||||
const AppError = require('../middleware/AppError.js');
|
const AppError = require('../middleware/AppError.js');
|
||||||
const { USER_ALREADY_EXISTS } = require('../constants/errorCodes');
|
const { USER_ALREADY_EXISTS } = require('../constants/errorCodes');
|
||||||
const Folders = require('../models/folders.js');
|
|
||||||
|
|
||||||
class Users {
|
class Users {
|
||||||
constructor(db) {
|
constructor(db, foldersModel) {
|
||||||
console.log("Users constructor: db", db)
|
console.log("Users constructor: db", db)
|
||||||
this.db = db;
|
this.db = db;
|
||||||
|
this.folders = foldersModel;
|
||||||
}
|
}
|
||||||
|
|
||||||
async hashPassword(password) {
|
async hashPassword(password) {
|
||||||
|
|
@ -45,7 +45,7 @@ class Users {
|
||||||
const userId = result.insertedId.toString();
|
const userId = result.insertedId.toString();
|
||||||
|
|
||||||
const folderTitle = 'Dossier par Défaut';
|
const folderTitle = 'Dossier par Défaut';
|
||||||
await Folders.create(folderTitle, userId);
|
await this.folders.create(folderTitle, userId);
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue