feat: open page api
This commit is contained in:
12
apps/openpage-api/app/github/forks/route.ts
Normal file
12
apps/openpage-api/app/github/forks/route.ts
Normal file
@@ -0,0 +1,12 @@
|
||||
import { NextResponse } from 'next/server';
|
||||
|
||||
import { requestHandler } from '@/app/request-handler';
|
||||
|
||||
export const GET = requestHandler(async () => {
|
||||
const res = await fetch('https://api.github.com/repos/documenso/documenso');
|
||||
const { forks_count } = await res.json();
|
||||
|
||||
return NextResponse.json({
|
||||
data: forks_count,
|
||||
});
|
||||
});
|
||||
14
apps/openpage-api/app/github/issues/route.ts
Normal file
14
apps/openpage-api/app/github/issues/route.ts
Normal file
@@ -0,0 +1,14 @@
|
||||
import { NextResponse } from 'next/server';
|
||||
|
||||
import { requestHandler } from '@/app/request-handler';
|
||||
|
||||
export const GET = requestHandler(async () => {
|
||||
const res = await fetch(
|
||||
'https://api.github.com/search/issues?q=repo:documenso/documenso+type:issue+state:open&page=0&per_page=1',
|
||||
);
|
||||
const { total_count } = await res.json();
|
||||
|
||||
return NextResponse.json({
|
||||
data: total_count,
|
||||
});
|
||||
});
|
||||
14
apps/openpage-api/app/github/prs/route.ts
Normal file
14
apps/openpage-api/app/github/prs/route.ts
Normal file
@@ -0,0 +1,14 @@
|
||||
import { NextResponse } from 'next/server';
|
||||
|
||||
import { requestHandler } from '@/app/request-handler';
|
||||
|
||||
export const GET = requestHandler(async () => {
|
||||
const res = await fetch(
|
||||
'https://api.github.com/search/issues?q=repo:documenso/documenso/+is:pr+merged:>=2010-01-01&page=0&per_page=1',
|
||||
);
|
||||
const { total_count } = await res.json();
|
||||
|
||||
return NextResponse.json({
|
||||
data: total_count,
|
||||
});
|
||||
});
|
||||
17
apps/openpage-api/app/github/route.ts
Normal file
17
apps/openpage-api/app/github/route.ts
Normal file
@@ -0,0 +1,17 @@
|
||||
import { type NextRequest, NextResponse } from 'next/server';
|
||||
|
||||
const paths = [
|
||||
{ path: '/forks', description: 'GitHub Forks' },
|
||||
{ path: '/stars', description: 'GitHub Stars' },
|
||||
{ path: '/issues', description: 'GitHub Merged Issues' },
|
||||
{ path: '/prs', description: 'GitHub Pull Request' },
|
||||
];
|
||||
|
||||
export function GET(request: NextRequest) {
|
||||
const url = request.nextUrl.toString();
|
||||
const apis = paths.map(({ path, description }) => {
|
||||
return { path: url + path, description };
|
||||
});
|
||||
|
||||
return NextResponse.json(apis);
|
||||
}
|
||||
12
apps/openpage-api/app/github/stars/route.ts
Normal file
12
apps/openpage-api/app/github/stars/route.ts
Normal file
@@ -0,0 +1,12 @@
|
||||
import { NextResponse } from 'next/server';
|
||||
|
||||
import { requestHandler } from '@/app/request-handler';
|
||||
|
||||
export const GET = requestHandler(async () => {
|
||||
const res = await fetch('https://api.github.com/repos/documenso/documenso');
|
||||
const { stargazers_count } = await res.json();
|
||||
|
||||
return NextResponse.json({
|
||||
data: stargazers_count,
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user