{"size": 880, "ext": "js", "max_stars_repo_path": "server/src/routes/api/communities.js", "max_stars_repo_name": "leonprou/CLN-community-app", "max_stars_repo_stars_event_min_datetime": "2018-05-21T18:36:21.000Z", "max_stars_repo_stars_event_max_datetime": "2018-06-20T03:15:31.000Z", "max_issues_repo_path": "server/src/routes/api/communities.js", "max_issues_repo_name": "leonprou/CLN-community-app", "max_issues_repo_issues_event_min_datetime": "2018-08-14T09:19:57.000Z", "max_issues_repo_issues_event_max_datetime": "2021-05-07T03:36:52.000Z", "max_forks_repo_path": "server/src/routes/api/communities.js", "max_forks_repo_name": "leonprou/CLN-community-app", "max_forks_repo_forks_event_min_datetime": "2018-07-12T12:29:41.000Z", "max_forks_repo_forks_event_max_datetime": "2018-08-07T10:59:04.000Z"}
{"max_stars_count": 3, "max_issues_count": 27, "max_forks_count": 3, "avg_line_length": 28.3870967742, "max_line_length": 81, "alphanum_fraction": 0.7340909091}
const router = require('express').Router()
const mongoose = require('mongoose')
const Community = mongoose.model('Community')

/**
 * @apiDefine CommunityData
 * @apiSuccess {Boolean} isClosed
 * @apiSuccess {String} communityAddress
 * @apiSuccess {String} homeTokenAddress
 * @apiSuccess {String} foreignTokenAddress
 * @apiSuccess {String} foreignBridgeAddress
 * @apiSuccess {String} homeBridgeAddress
 */

/**
 * @api {get} /communities/:communityAddress Fetch community by community address
 * @apiName GetCommunity
 * @apiGroup Community
 *
 * @apiParam {String} communityAddress Community address
 *
 * @apiUse CommunityData
 */
router.get('/:communityAddress', async (req, res, next) => {
  const { communityAddress } = req.params
  const community = await Community.findOne({ communityAddress }).lean()
  return res.json({ data: community })
})

module.exports = router
