3 var RepoService = require('gitter-web-github').GitHubRepoService;
4 var StatusError = require('statuserror');
6 module.exports = function(req, res, next) {
7 const type = req.query.type ? String(req.query.type) : null;
8 const linkPath = req.query.linkPath ? String(req.query.linkPath) : null;
10 if (type !== 'GH_REPO') return next(new StatusError(400, 'only GH_REPO type supported'));
11 if (!linkPath) return next(new StatusError(400, 'repo parameter required'));
12 const repoService = new RepoService(req.user);
14 return repoService.getRepo(linkPath).then(function(repo) {
15 if (!repo) return next(new StatusError(204, 'repo not found'));