This repository was archived by the owner on May 11, 2025. It is now read-only.
File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -49,7 +49,7 @@ class Cache {
4949 } , 1800 ) ;
5050 }
5151
52- wrap ( func : ( params : any [ ] ) => Promise < any > ) : ( ...params : any [ ] ) => Promise < any > {
52+ wrap ( func : ( ... params : any [ ] ) => Promise < any > ) : ( ...params : any [ ] ) => Promise < any > {
5353 /**
5454 * Async Function Cache.
5555 */
Original file line number Diff line number Diff line change 11const axios = require ( "axios" ) ;
22const conf = require ( "./config" ) ;
3+ const cache = require ( "./cache" ) . cache ;
4+
35axios . defaults . baseURL = "https://api.github.com" ;
46
57export function sort ( arr : number [ ] ) : number [ ] {
@@ -66,9 +68,25 @@ export function getLicense(license: object | undefined | null): string {
6668 return license ? license [ 'spdx_id' ] : "Empty" ;
6769}
6870
69- export async function isAuthenticated ( user ) : Promise < boolean > {
71+ async function _isAuthenticated ( user ) : Promise < boolean > {
7072 user = user . trim ( ) ;
71- return ( ! ! user . length ) &&
72- ( conf . requires . includes ( "*" ) || conf . requires . includes ( user ) ) &&
73- ( ( await requestUser ( user ) ) [ 'message' ] !== "Not Found" ) ;
74- }
73+ try {
74+ return ( ! ! user . length ) &&
75+ ( conf . requires . includes ( "*" ) || conf . requires . includes ( user ) ) &&
76+ ( ( await requestUser ( user ) ) [ 'message' ] !== "Not Found" ) ;
77+ } catch {
78+ return false ;
79+ }
80+ }
81+ export const isAuthenticated = cache . wrap ( _isAuthenticated ) ;
82+
83+ async function _isExistRepo ( user , repo ) : Promise < boolean > {
84+ user = user . trim ( ) ; repo = repo . trim ( ) ;
85+ try {
86+ return await isAuthenticated ( user ) &&
87+ ( ( await requestRepo ( user , repo ) ) [ 'message' ] !== "Not Found" ) ;
88+ } catch {
89+ return false ;
90+ }
91+ }
92+ export const isExistRepo = cache . wrap ( _isExistRepo ) ;
You can’t perform that action at this time.
0 commit comments