refactor(skydive): replace MongoDB User with MySQL UserService

All skydive routes now fetch users via UserService (MySQL) instead of
mongoose.model('User'). Key changes:
- user._id.toString() → user.id (same UUID, different source)
- User.findOne({ username }) → UserService.getUserByUsername()
- /feed route migrated to async/await using UserService.getUserFollowed()
  to resolve the following list from the MySQL Follower table
- jump/file/application author set as user.id (UUID string) instead of
  the full Mongoose document
- jump.toJSONFor(null) — following field in responses is now always false
  until Jump model is migrated away from MongoDB User dependency
- user.controller: licence/poids/bg_image routed to SkydiverProfileService
  fixing the silent Sequelize save bug for those fields
This commit is contained in:
2026-04-26 00:05:57 +02:00
parent ad7fc4384a
commit 5bcecd01f9
9 changed files with 148 additions and 446 deletions
+7 -9
View File
@@ -3,9 +3,9 @@ var router = require('express').Router(),
Qcm = mongoose.model('Qcm'),
QcmCategory = mongoose.model('QcmCategory'),
QcmQuestion = mongoose.model('QcmQuestion'),
QcmChoice = mongoose.model('QcmChoice'),
User = mongoose.model('User');
QcmChoice = mongoose.model('QcmChoice');
const auth = require('../../../middlewares/auth');
const { UserService } = require('../../../services');
// Preload qcm objects on routes with ':type'
router.param('type', function (req, res, next, type) {
@@ -37,7 +37,7 @@ router.param('type', function (req, res, next, type) {
*/
router.get('/', auth.required, function (req, res, next) {
Promise.all([
req.payload ? User.findById(req.payload.id) : null
req.payload ? UserService.getUserById(req.payload.id) : null
]).then(function (results) {
let user = results[0];
if (!user) {
@@ -52,7 +52,7 @@ router.get('/', auth.required, function (req, res, next) {
*/
router.get('/type/:type', auth.required, function (req, res, next) {
Promise.all([
req.payload ? User.findById(req.payload.id) : null
req.payload ? UserService.getUserById(req.payload.id) : null
]).then(function (results) {
let user = results[0];
if (!user) {
@@ -67,14 +67,13 @@ router.get('/type/:type', auth.required, function (req, res, next) {
*/
router.post('/choices/', auth.required, function (req, res, next) {
Promise.all([
req.payload ? User.findById(req.payload.id) : null,
req.payload ? UserService.getUserById(req.payload.id) : null,
QcmQuestion
.findOne({num: req.body.question.num})
.populate('choices')
.exec()
]).then(async function (results) {
const user = results[0];
//let numero = (results[1][0].numero + 1);
if (!user) {
return res.status(401).json({ errors: { "Unauthorized": "autentification requise" } });
}
@@ -113,14 +112,13 @@ router.post('/choices/', auth.required, function (req, res, next) {
*/
router.post('/questions/', auth.required, function (req, res, next) {
Promise.all([
req.payload ? User.findById(req.payload.id) : null,
req.payload ? UserService.getUserById(req.payload.id) : null,
QcmCategory
.findOne({num: req.body.category.num})
.populate('questions')
.exec()
]).then(async function (results) {
const user = results[0];
//let numero = (results[1][0].numero + 1);
if (!user) {
return res.status(401).json({ errors: { "Unauthorized": "autentification requise" } });
}
@@ -154,4 +152,4 @@ router.post('/questions/', auth.required, function (req, res, next) {
}).catch(next);
});
module.exports = router;
module.exports = router;