slate/pages/api/hydrate.js

19 lines
571 B
JavaScript
Raw Normal View History

import * as ViewerManager from "~/node_common/managers/viewer";
import * as Utilities from "~/node_common/utilities";
export default async (req, res) => {
const id = Utilities.getIdFromCookie(req);
2021-06-09 01:53:30 +03:00
if (!id) {
return res.status(401).send({ decorator: "SERVER_NOT_AUTHENTICATED", error: true });
}
const data = await ViewerManager.getById({ id });
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-10-29 21:39:40 +03:00
return res.status(200).send({ decorator: "SERVER_HYDRATE", success: true, data });
};