getting org members
This commit is contained in:
@@ -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);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user