Skip to content

Commit f5a0b39

Browse files
committed
refactor: move stats routes
1 parent 5c59eeb commit f5a0b39

File tree

3 files changed

+21
-13
lines changed

3 files changed

+21
-13
lines changed

src/router/index.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import type { Request, Response } from "express";
22
import type { Probot } from "probot";
33
import express from "express";
4-
import getProbotStats from "@/src/router/probot-stats.ts";
4+
import getStatsHandlers from "@/src/router/stats.ts";
55
import getRepoHandlers from "@/src/router/repo-handler.ts";
66

77
const createRouter = (app: Probot) => {
@@ -15,7 +15,8 @@ const createRouter = (app: Probot) => {
1515
res.json({ status: "pong" });
1616
});
1717

18-
router.get("/probot/stats", getProbotStats);
18+
const { probotStatsHandler } = getStatsHandlers(app);
19+
router.get("/probot/stats", probotStatsHandler);
1920

2021
const { checkHandler } = getRepoHandlers(app);
2122
router.get("/check/:owner/:repo", checkHandler);

src/router/probot-stats.ts

Lines changed: 0 additions & 11 deletions
This file was deleted.

src/router/stats.ts

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
import type { Request, Response } from "express";
2+
import { Probot } from "probot";
3+
4+
function getStatsHandlers(_app: Probot) {
5+
async function probotStatsHandler(_req: Request, res: Response) {
6+
const response = await fetch(
7+
"https://raw.githack.com/pull-app/stats/master/stats.json",
8+
);
9+
const data = await response.json();
10+
res.json(data);
11+
}
12+
13+
return {
14+
probotStatsHandler,
15+
};
16+
}
17+
18+
export default getStatsHandlers;

0 commit comments

Comments
 (0)