mirror of
https://github.com/muerwre/orchidmap-front.git
synced 2025-04-25 11:06:40 +07:00
backend: route save / restore
This commit is contained in:
parent
032821329b
commit
d932fcb287
17 changed files with 163 additions and 43 deletions
23
backend/routes/route/get.js
Normal file
23
backend/routes/route/get.js
Normal file
|
@ -0,0 +1,23 @@
|
|||
const { User, Route } = require('../../models');
|
||||
|
||||
module.exports = async (req, res) => {
|
||||
const { query: { id, token, name } } = req;
|
||||
|
||||
if (!name) return res.send({ success: false, mode: 'not_found_1' });
|
||||
|
||||
const exists = await Route.findOne({ _id: name }).populate('owner');
|
||||
|
||||
if (!exists) return res.send({ success: false, mode: 'not_found_2' });
|
||||
const data = exists.toObject();
|
||||
|
||||
return res.send({
|
||||
success: true,
|
||||
...data,
|
||||
address: exists._id,
|
||||
owner: {
|
||||
...data.owner,
|
||||
id: data.owner._id,
|
||||
}
|
||||
});
|
||||
};
|
||||
|
Loading…
Add table
Add a link
Reference in a new issue