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);
|
|
|
|
if (!id) {
|
2020-09-03 03:21:29 +03:00
|
|
|
return res
|
|
|
|
.status(500)
|
|
|
|
.send({ decorator: "SERVER_HYDRATE_FAILURE", 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-09-03 03:21:29 +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-09-03 03:21:29 +03:00
|
|
|
return res
|
|
|
|
.status(200)
|
|
|
|
.send({ decorator: "SERVER_HYDRATE", success: true, data });
|
2020-07-17 13:24:20 +03:00
|
|
|
};
|