Skip to content

Commit

Permalink
improve: code condense
Browse files Browse the repository at this point in the history
  • Loading branch information
gaomingzhao666 committed Jul 22, 2024
1 parent 8dd6b4f commit 93fe67f
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 33 deletions.
15 changes: 15 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"type": "chrome",
"request": "launch",
"name": "Launch Chrome against localhost",
"url": "http://localhost:8080",
"webRoot": "${workspaceFolder}"
}
]
}
3 changes: 0 additions & 3 deletions pages/index/contact.vue
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,4 @@ useSeoMeta({
title: 'Contact me',
description: 'Find my contact information',
})
const index = useIndexStore()
console.log(index.colorMode.value)
</script>
55 changes: 25 additions & 30 deletions server/api/user/githubUserInfo.get.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,37 +2,32 @@ import { Octokit } from 'octokit'
import { githubToken } from '~/server/utils/githubInfo'

export default defineEventHandler(async (event) => {
try {
const getGithubUserInfo = async () => {
const octokit = new Octokit({
auth: githubToken,
})
const getGithubUserInfo = async () => {
const octokit = new Octokit({
auth: githubToken,
})

const data = await octokit.request('GET /user', {
headers: {
'X-GitHub-Api-Version': '2022-11-28',
},
})
return data
}
const data = await octokit.request('GET /user', {
headers: {
'X-GitHub-Api-Version': '2022-11-28',
},
})
return data
}

const githubUserInfo = await getGithubUserInfo()
const githubUserInfo = await getGithubUserInfo()

if (githubUserInfo.status === 200) {
setResponseStatus(event, 200)
return <githubUserInfoGet>{
status: true,
data: githubUserInfo,
}
} else
return <errorType>{
status: false,
data: {
message: 'Github api encountered problem',
},
}
} catch (error) {
console.log('Error in githubUserInfo module')
console.log(error)
}
if (githubUserInfo.status === 200) {
setResponseStatus(event, 200)
return <githubUserInfoGet>{
status: true,
data: githubUserInfo,
}
} else
return <errorType>{
status: false,
data: {
message: 'Github api encountered problem',
},
}
})

0 comments on commit 93fe67f

Please sign in to comment.