getting org members

This commit is contained in:
metacryst
2026-01-13 14:27:44 -06:00
parent 134a6b8471
commit 237bbfedd4
7 changed files with 59 additions and 37 deletions

View File

@@ -37,28 +37,40 @@ class Server {
/* Site */
router.post('/free', this.newUserSubmission)
router.get('/db/images/*', this.getUserImage)
router.get('/app/comaldata', this.getComalData)
router.get('/app/orgdata/*', this.getOrgData)
router.get('/*', this.get)
return router
}
getComalData = async (req, res, next) => {
getOrgData = async (req, res, next) => {
try {
const pathOne = path.join(this.ComalPath, "db", "join.json");
const pathTwo = path.join(this.ComalPath, "db", "contact.json");
const networkId = req.params[0]
const [joinRaw, contactRaw] = await Promise.all([
fs.promises.readFile(pathOne, "utf8"),
fs.promises.readFile(pathTwo, "utf8")
]);
const join = joinRaw.trim() ? JSON.parse(joinRaw) : [];
const contact = contactRaw.trim() ? JSON.parse(contactRaw) : [];
res.json({
join,
contact
});
if(networkId === "1") {
const pathOne = path.join(this.ComalPath, "db", "join.json");
const pathTwo = path.join(this.ComalPath, "db", "contact.json");
const [joinRaw, contactRaw] = await Promise.all([
fs.promises.readFile(pathOne, "utf8"),
fs.promises.readFile(pathTwo, "utf8")
]);
const join = joinRaw.trim() ? JSON.parse(joinRaw) : [];
const contact = contactRaw.trim() ? JSON.parse(contactRaw) : [];
const members = db.members.getByNetwork(networkId)
res.json({
join,
contact,
members
});
} else {
const members = db.members.getByNetwork(networkId)
res.json({
members
});
}
} catch (err) {
next(err);
}