From 985448d5dd006da7412a0094eff19d0d532cefd1 Mon Sep 17 00:00:00 2001 From: Chris Date: Thu, 26 Sep 2024 17:57:43 +0800 Subject: [PATCH] chore: update --- .eslintcache | 2 +- server/api/contribution.ts | 25 ++++++++++++++++++++----- 2 files changed, 21 insertions(+), 6 deletions(-) diff --git a/.eslintcache b/.eslintcache index a0f6d57..a751aa4 100644 --- a/.eslintcache +++ b/.eslintcache @@ -1 +1 @@ -[{"/Users/chris/i/chris.me/components/PageHeader.vue":"1","/Users/chris/i/chris.me/components/PersonInfo.vue":"2","/Users/chris/i/chris.me/components/nav/NavFooter.vue":"3","/Users/chris/i/chris.me/uno.config.ts":"4","/Users/chris/i/chris.me/app.vue":"5","/Users/chris/i/chris.me/components/DrakToggle.vue":"6","/Users/chris/i/chris.me/components/icons/IconsElk.vue":"7","/Users/chris/i/chris.me/components/nav/NavHeader.vue":"8","/Users/chris/i/chris.me/components/user/Avatar.vue":"9","/Users/chris/i/chris.me/pages/projects.vue":"10"},{"size":267,"mtime":1718965939791,"results":"11","hashOfConfig":"12"},{"size":1648,"mtime":1718965939792,"results":"13","hashOfConfig":"12"},{"size":481,"mtime":1718965939792,"results":"14","hashOfConfig":"12"},{"size":4992,"mtime":1719812740541,"results":"15","hashOfConfig":"16"},{"size":1527,"mtime":1719821733498,"results":"17","hashOfConfig":"18"},{"size":1917,"mtime":1719815277538,"results":"19","hashOfConfig":"18"},{"size":252,"mtime":1719812135212,"results":"20","hashOfConfig":"18"},{"size":1304,"mtime":1719816196647,"results":"21","hashOfConfig":"18"},{"size":499,"mtime":1719816044862,"results":"22","hashOfConfig":"18"},{"size":723,"mtime":1719816283426,"results":"23","hashOfConfig":"18"},{"filePath":"24","messages":"25","suppressedMessages":"26","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},"mzpfdo",{"filePath":"27","messages":"28","suppressedMessages":"29","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"30","messages":"31","suppressedMessages":"32","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"33","messages":"34","suppressedMessages":"35","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},"1p8jpht",{"filePath":"36","messages":"37","suppressedMessages":"38","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},"my6kpd",{"filePath":"39","messages":"40","suppressedMessages":"41","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"42","messages":"43","suppressedMessages":"44","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"45","messages":"46","suppressedMessages":"47","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"48","messages":"49","suppressedMessages":"50","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"51","messages":"52","suppressedMessages":"53","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},"/Users/chris/i/chris.me/components/PageHeader.vue",[],[],"/Users/chris/i/chris.me/components/PersonInfo.vue",[],[],"/Users/chris/i/chris.me/components/nav/NavFooter.vue",[],[],"/Users/chris/i/chris.me/uno.config.ts",[],["54"],"/Users/chris/i/chris.me/app.vue",[],[],"/Users/chris/i/chris.me/components/DrakToggle.vue",[],[],"/Users/chris/i/chris.me/components/icons/IconsElk.vue",[],[],"/Users/chris/i/chris.me/components/nav/NavHeader.vue",[],[],"/Users/chris/i/chris.me/components/user/Avatar.vue",[],[],"/Users/chris/i/chris.me/pages/projects.vue",[],[],{"ruleId":"55","severity":2,"message":"56","line":52,"column":9,"nodeType":"57","messageId":"58","endLine":52,"endColumn":18,"suppressions":"59"},"regexp/no-super-linear-backtracking","The quantifier '.+?' can exchange characters with '.+'. Using any string accepted by /:+/, this can be exploited to cause at least polynomial backtracking. This might cause exponential backtracking.","Literal","trade",["60"],{"kind":"61","justification":"62"},"directive",""] \ No newline at end of file +[{"/Users/chris/i/chris.me/components/PageHeader.vue":"1","/Users/chris/i/chris.me/components/PersonInfo.vue":"2","/Users/chris/i/chris.me/components/nav/NavFooter.vue":"3","/Users/chris/i/chris.me/uno.config.ts":"4","/Users/chris/i/chris.me/app.vue":"5","/Users/chris/i/chris.me/components/DrakToggle.vue":"6","/Users/chris/i/chris.me/components/icons/IconsElk.vue":"7","/Users/chris/i/chris.me/components/nav/NavHeader.vue":"8","/Users/chris/i/chris.me/components/user/Avatar.vue":"9","/Users/chris/i/chris.me/pages/projects.vue":"10","/Users/chris/i/chris.me/components/ImgBlurHash.vue":"11","/Users/chris/i/chris.me/components/repo/RepoCard.vue":"12","/Users/chris/i/chris.me/layouts/default.vue":"13","/Users/chris/i/chris.me/nuxt.config.ts":"14","/Users/chris/i/chris.me/pages/index.vue":"15","/Users/chris/i/chris.me/pages/posts.vue":"16","/Users/chris/i/chris.me/pages/talks.vue":"17","/Users/chris/i/chris.me/server/api/contribution.ts":"18","/Users/chris/i/chris.me/server/api/repos.ts":"19","/Users/chris/i/chris.me/server/api/user.ts":"20","/Users/chris/i/chris.me/server/utils/github.ts":"21"},{"size":267,"mtime":1718965939791,"results":"22","hashOfConfig":"23"},{"size":1648,"mtime":1718965939792,"results":"24","hashOfConfig":"23"},{"size":482,"mtime":1727257905902,"results":"25","hashOfConfig":"26"},{"size":4992,"mtime":1719812740541,"results":"27","hashOfConfig":"28"},{"size":1496,"mtime":1727342153908,"results":"29","hashOfConfig":"26"},{"size":1917,"mtime":1719815277538,"results":"30","hashOfConfig":"31"},{"size":252,"mtime":1719812135212,"results":"32","hashOfConfig":"31"},{"size":1343,"mtime":1727317617655,"results":"33","hashOfConfig":"26"},{"size":499,"mtime":1719816044862,"results":"34","hashOfConfig":"31"},{"size":877,"mtime":1727251853728,"results":"35","hashOfConfig":"26"},{"size":1752,"mtime":1727342952252,"results":"36","hashOfConfig":"26"},{"size":1854,"mtime":1727251760444,"results":"37","hashOfConfig":"26"},{"size":509,"mtime":1727342233093,"results":"38","hashOfConfig":"26"},{"size":1040,"mtime":1727342539248,"results":"39","hashOfConfig":"40"},{"size":520,"mtime":1727317185962,"results":"41","hashOfConfig":"26"},{"size":104,"mtime":1727251295530,"results":"42","hashOfConfig":"26"},{"size":84,"mtime":1727251260868,"results":"43","hashOfConfig":"26"},{"size":369,"mtime":1727343125754,"results":"44","hashOfConfig":"45"},{"size":1229,"mtime":1727342733876},{"size":170,"mtime":1727342647933,"results":"46","hashOfConfig":"45"},{"size":212,"mtime":1727342611227,"results":"47","hashOfConfig":"45"},{"filePath":"48","messages":"49","suppressedMessages":"50","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},"mzpfdo",{"filePath":"51","messages":"52","suppressedMessages":"53","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"54","messages":"55","suppressedMessages":"56","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},"75pghd",{"filePath":"57","messages":"58","suppressedMessages":"59","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},"1p8jpht",{"filePath":"60","messages":"61","suppressedMessages":"62","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"63","messages":"64","suppressedMessages":"65","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},"my6kpd",{"filePath":"66","messages":"67","suppressedMessages":"68","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"69","messages":"70","suppressedMessages":"71","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"72","messages":"73","suppressedMessages":"74","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"75","messages":"76","suppressedMessages":"77","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"78","messages":"79","suppressedMessages":"80","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"81","messages":"82","suppressedMessages":"83","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"84","messages":"85","suppressedMessages":"86","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"87","messages":"88","suppressedMessages":"89","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},"12bxb1y",{"filePath":"90","messages":"91","suppressedMessages":"92","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"93","messages":"94","suppressedMessages":"95","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"96","messages":"97","suppressedMessages":"98","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"99","messages":"100","suppressedMessages":"101","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},"1h4s7jb",{"filePath":"102","messages":"103","suppressedMessages":"104","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"105","messages":"106","suppressedMessages":"107","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},"/Users/chris/i/chris.me/components/PageHeader.vue",[],[],"/Users/chris/i/chris.me/components/PersonInfo.vue",[],[],"/Users/chris/i/chris.me/components/nav/NavFooter.vue",[],[],"/Users/chris/i/chris.me/uno.config.ts",[],["108"],"/Users/chris/i/chris.me/app.vue",[],[],"/Users/chris/i/chris.me/components/DrakToggle.vue",[],[],"/Users/chris/i/chris.me/components/icons/IconsElk.vue",[],[],"/Users/chris/i/chris.me/components/nav/NavHeader.vue",[],[],"/Users/chris/i/chris.me/components/user/Avatar.vue",[],[],"/Users/chris/i/chris.me/pages/projects.vue",[],[],"/Users/chris/i/chris.me/components/ImgBlurHash.vue",[],[],"/Users/chris/i/chris.me/components/repo/RepoCard.vue",[],[],"/Users/chris/i/chris.me/layouts/default.vue",[],[],"/Users/chris/i/chris.me/nuxt.config.ts",[],[],"/Users/chris/i/chris.me/pages/index.vue",[],[],"/Users/chris/i/chris.me/pages/posts.vue",[],[],"/Users/chris/i/chris.me/pages/talks.vue",[],[],"/Users/chris/i/chris.me/server/api/contribution.ts",[],[],"/Users/chris/i/chris.me/server/api/user.ts",[],[],"/Users/chris/i/chris.me/server/utils/github.ts",[],[],{"ruleId":"109","severity":2,"message":"110","line":52,"column":9,"nodeType":"111","messageId":"112","endLine":52,"endColumn":18,"suppressions":"113"},"regexp/no-super-linear-backtracking","The quantifier '.+?' can exchange characters with '.+'. Using any string accepted by /:+/, this can be exploited to cause at least polynomial backtracking. This might cause exponential backtracking.","Literal","trade",["114"],{"kind":"115","justification":"116"},"directive",""] \ No newline at end of file diff --git a/server/api/contribution.ts b/server/api/contribution.ts index 21a45d9..537fce8 100644 --- a/server/api/contribution.ts +++ b/server/api/contribution.ts @@ -1,11 +1,26 @@ -import type { ContributeData } from '~/types' +import { useOctokit } from '../utils/github' export default defineEventHandler(async (event) => { - if (import.meta.dev) - return (await import('~/mock/contributions.json')).default as ContributeData + // if (import.meta.dev) + // return (await import('~/mock/contributions.json')).default as ContributeData const { name, year } = getQuery(event) - const API = `https://github-contributions-api.jogruber.de/v4/${name}?y=${year}` + const octokit = useOctokit() + try { + const response = await octokit.request('GET /users/{username}/events', { + username: name as string, + per_page: 100, + }) - return $fetch(API) + const contributions = response.data.filter((d) => { + const eventYear = new Date(d.created_at!).getFullYear() + return eventYear === Number.parseInt(year as string, 10) + }) + + return contributions + } + catch (error) { + console.error('Error fetching contributions:', error) + throw error + } })