mirror of
https://github.com/muerwre/orchidmap-front.git
synced 2025-04-25 11:06:40 +07:00
backend: fixed loading of routes
This commit is contained in:
parent
b8431abeeb
commit
cc4dff0ca1
10 changed files with 73 additions and 74 deletions
|
@ -4,17 +4,22 @@ const { generateGuest, generateRandomUrl } = require('./guest');
|
|||
module.exports = async (req, res) => {
|
||||
const { id, token } = req.query;
|
||||
|
||||
const user = await User.findOne({ _id: id, token }).populate({
|
||||
path: 'routes',
|
||||
options: {
|
||||
limit: 100,
|
||||
sort: { updated_at: -1 },
|
||||
}
|
||||
});
|
||||
const user = await User.findOne({ _id: id, token })
|
||||
.populate({
|
||||
path: 'routes',
|
||||
select: '_id title distance owner updated_at',
|
||||
options: {
|
||||
limit: 100,
|
||||
sort: { updated_at: -1 },
|
||||
}
|
||||
});
|
||||
|
||||
const random_url = await generateRandomUrl();
|
||||
|
||||
if (user) {
|
||||
return res.send({ success: true, ...user.toObject(), id: user._id, random_url });
|
||||
return res.send({
|
||||
success: true, ...user.toObject(), id: user._id, random_url
|
||||
});
|
||||
}
|
||||
|
||||
const guest = await generateGuest();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue