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
+6 -6
View File
@@ -1,13 +1,13 @@
var router = require('express').Router(),
mongoose = require('mongoose'),
Jump = mongoose.model('Jump'),
User = mongoose.model('User');
Jump = mongoose.model('Jump');
const auth = require('../../../middlewares/auth'),
queries = require('../../queries');
const { UserService } = require('../../../services');
router.get('/allByOaci', auth.required, function (req, res, next) {
User.findById(req.payload.id).then(function (user) {
UserService.getUserById(req.payload.id).then(function (user) {
if (!user) {
return res.status(401).json({ errors: { "Unauthorized": "autentification requise" } });
}
@@ -19,7 +19,7 @@ router.get('/allByOaci', auth.required, function (req, res, next) {
if (typeof req.query.offset !== 'undefined') {
offset = req.query.offset;
}
let query = queries.getDropZonesByOaciQuery(user._id.toString());
let query = queries.getDropZonesByOaciQuery(user.id);
Jump.aggregate(query)
.skip(Number(offset))
.limit(Number(limit))
@@ -37,7 +37,7 @@ router.get('/allByOaci', auth.required, function (req, res, next) {
});
router.get('/allByOaciByYear', auth.required, function (req, res, next) {
User.findById(req.payload.id).then(function (user) {
UserService.getUserById(req.payload.id).then(function (user) {
if (!user) {
return res.status(401).json({ errors: { "Unauthorized": "autentification requise" } });
}
@@ -49,7 +49,7 @@ router.get('/allByOaciByYear', auth.required, function (req, res, next) {
if (typeof req.query.offset !== 'undefined') {
offset = req.query.offset;
}
let query = queries.getDropZonesByOaciByYearQuery(user._id.toString());
let query = queries.getDropZonesByOaciByYearQuery(user.id);
Jump.aggregate(query)
.skip(Number(offset))
.limit(Number(limit))