1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
import { quickShareApiCheckLogout } from "https://esm.town/v/mcwhittemore/quickShareApiCheckLogout";
import { quickShareApiGetUser } from "https://esm.town/v/mcwhittemore/quickShareApiGetUser";
export let quickShareApi = async (req, res) => {
const { session, endpoint, params } = req.body;
const hasValidSession = session ? true : false; //await @me.quickShareCheckSession(session);
if (hasValidSession === false) {
return res.json({
content: "you should login",
auth: '<a href="https://api.val.town/express/@mcwhittemore.quickShareGithubAuthStart">Login</a>',
});
}
let result = null;
if (endpoint === "get-user") {
result = await quickShareApiGetUser({ session });
} else if (endpoint === "quickShareApiCheckLogout") {
result = await quickShareApiCheckLogout({ session, params });
}
if (result === null) return res.json(404, { content: "Not Found" });
res.json(result);
};