2020-07-24 03:22:22 +03:00
|
|
|
import * as ViewerManager from "~/node_common/managers/viewer";
|
2020-07-22 08:53:29 +03:00
|
|
|
import * as Utilities from "~/node_common/utilities";
|
2020-07-17 13:24:20 +03:00
|
|
|
|
|
|
|
export default async (req, res) => {
|
2020-07-22 13:51:40 +03:00
|
|
|
const id = Utilities.getIdFromCookie(req);
|
2021-06-09 01:53:30 +03:00
|
|
|
|
2020-07-22 13:51:40 +03:00
|
|
|
if (!id) {
|
2021-03-07 23:53:54 +03:00
|
|
|
return res.status(401).send({ decorator: "SERVER_NOT_AUTHENTICATED", error: true });
|
2020-07-22 08:53:29 +03:00
|
|
|
}
|
|
|
|
|
2020-07-24 03:22:22 +03:00
|
|
|
const data = await ViewerManager.getById({ id });
|
2020-07-17 13:24:20 +03:00
|
|
|
|
2020-08-24 08:59:37 +03:00
|
|
|
if (!data) {
|
2020-10-29 21:39:40 +03:00
|
|
|
return res.status(500).send({ decorator: "SERVER_VIEWER_DATA_ERROR", error: true, data: null });
|
2020-08-24 08:59:37 +03:00
|
|
|
}
|
|
|
|
|
2020-10-29 21:39:40 +03:00
|
|
|
return res.status(200).send({ decorator: "SERVER_HYDRATE", success: true, data });
|
2020-07-17 13:24:20 +03:00
|
|
|
};
|