refactor: reorder /begin /add /end routes
This commit is contained in:
parent
6b98655c92
commit
33e8cbdb83
|
@ -169,6 +169,28 @@ router.post(
|
|||
}),
|
||||
);
|
||||
|
||||
router.post(
|
||||
'/begin',
|
||||
auth.optional,
|
||||
wrapRoute(async (req, res) => {
|
||||
const user = await User.findById(req.body.id);
|
||||
|
||||
if (!user) {
|
||||
return res.sendStatus(401);
|
||||
}
|
||||
|
||||
const track = new Track(req.body.track);
|
||||
const trackData = new TrackData();
|
||||
track.trackData = trackData._id;
|
||||
track.author = user;
|
||||
|
||||
// remember which is the actively building track for this user
|
||||
currentTracks.set(user.id, track._id);
|
||||
|
||||
return res.sendStatus(200);
|
||||
}),
|
||||
);
|
||||
|
||||
router.post(
|
||||
'/add',
|
||||
auth.optional,
|
||||
|
@ -197,28 +219,6 @@ router.post(
|
|||
}),
|
||||
);
|
||||
|
||||
router.post(
|
||||
'/begin',
|
||||
auth.optional,
|
||||
wrapRoute(async (req, res) => {
|
||||
const user = await User.findById(req.body.id);
|
||||
|
||||
if (!user) {
|
||||
return res.sendStatus(401);
|
||||
}
|
||||
|
||||
const track = new Track(req.body.track);
|
||||
const trackData = new TrackData();
|
||||
track.trackData = trackData._id;
|
||||
track.author = user;
|
||||
|
||||
// remember which is the actively building track for this user
|
||||
currentTracks.set(user.id, track._id);
|
||||
|
||||
return res.sendStatus(200);
|
||||
}),
|
||||
);
|
||||
|
||||
router.post(
|
||||
'/end',
|
||||
auth.optional,
|
||||
|
|
Loading…
Reference in a new issue