File tree Expand file tree Collapse file tree 6 files changed +418
-81
lines changed
services/github/get-token Expand file tree Collapse file tree 6 files changed +418
-81
lines changed Original file line number Diff line number Diff line change 77 " github-copilot" ,
88 " openai-compatible"
99 ],
10- "bugs" : " https://github.com/ericc-ch/copilot-api/issues" ,
1110 "homepage" : " https://github.com/ericc-ch/copilot-api" ,
11+ "bugs" : " https://github.com/ericc-ch/copilot-api/issues" ,
1212 "repository" : {
1313 "type" : " git" ,
1414 "url" : " git+https://github.com/ericc-ch/copilot-api.git"
4343 "consola" : " ^3.4.0" ,
4444 "fetch-event-stream" : " ^0.1.5" ,
4545 "get-port-please" : " ^3.1.2" ,
46- "hono" : " ^4.7.2 " ,
46+ "hono" : " ^4.7.4 " ,
4747 "ofetch" : " ^1.4.1" ,
4848 "pathe" : " ^2.0.3" ,
4949 "srvx" : " ^0.1.4" ,
5050 "zod" : " ^3.24.2"
5151 },
5252 "devDependencies" : {
53- "@echristian/eslint-config" : " ^0.0.23 " ,
53+ "@echristian/eslint-config" : " ^0.0.32 " ,
5454 "@types/bun" : " ^1.2.4" ,
5555 "bumpp" : " ^10.0.3" ,
56- "eslint" : " ^9.21 .0" ,
56+ "eslint" : " ^9.22 .0" ,
5757 "knip" : " ^5.45.0" ,
5858 "lint-staged" : " ^15.4.3" ,
5959 "simple-git-hooks" : " ^2.11.1" ,
6060 "tinyexec" : " ^0.3.2" ,
6161 "tsup" : " ^8.4.0" ,
6262 "typescript" : " ^5.8.2" ,
63- "vitest" : " ^3.0.7 "
63+ "vitest" : " ^3.0.8 "
6464 }
6565}
Original file line number Diff line number Diff line change @@ -16,10 +16,7 @@ export const tokenService = {
1616 async getGithubToken ( ) : Promise < string | undefined > {
1717 if ( ! this . _tokens . github ) {
1818 try {
19- this . _tokens . github = await fs . readFile (
20- PATHS . GITHUB_TOKEN_PATH ,
21- "utf-8" ,
22- )
19+ this . _tokens . github = await fs . readFile ( PATHS . GITHUB_TOKEN_PATH , "utf8" )
2320 } catch ( error ) {
2421 consola . warn ( "Failed to load GitHub token" , error )
2522 }
Original file line number Diff line number Diff line change @@ -53,7 +53,7 @@ const main = defineCommand({
5353 } ,
5454 } ,
5555 run ( { args } ) {
56- const port = parseInt ( args . port , 10 )
56+ const port = Number . parseInt ( args . port , 10 )
5757
5858 return runServer ( {
5959 port,
Original file line number Diff line number Diff line change @@ -64,10 +64,10 @@ function handleFetchError(
6464 const headers : Record < string , string > = { }
6565
6666 // Forward all headers from the error response
67- error . response ?. headers . forEach ( ( value , key ) => {
67+ for ( const [ key , value ] of error . response ?. headers . entries ( ) ) {
6868 c . header ( key , value )
6969 headers [ key ] = value
70- } )
70+ }
7171
7272 // Log the error response
7373 void logger . logResponse (
@@ -107,10 +107,10 @@ async function handleResponseError(
107107 const headers : Record < string , string > = { }
108108
109109 // Forward all headers from the error response
110- error . headers . forEach ( ( value , key ) => {
110+ for ( const [ key , value ] of error . headers . entries ( ) ) {
111111 c . header ( key , value )
112112 headers [ key ] = value
113- } )
113+ }
114114
115115 // Log the error response
116116 void logger . logResponse (
Original file line number Diff line number Diff line change @@ -44,7 +44,9 @@ export async function getGitHubToken() {
4444 )
4545
4646 if ( pollResponse . access_token ) {
47- consola . info ( `Got token ${ pollResponse . access_token . replace ( / ./ g, "*" ) } ` )
47+ consola . info (
48+ `Got token ${ pollResponse . access_token . replaceAll ( / ./ g, "*" ) } ` ,
49+ )
4850 return pollResponse
4951 } else {
5052 // Interval is in seconds, we need to multiply by 1000 to get milliseconds
You can’t perform that action at this time.
0 commit comments