mirror of
				https://github.com/n8n-io/n8n-nodes-starter.git
				synced 2025-10-30 23:02:25 -05:00 
			
		
		
		
	Add nodes generated by the Node CLI, update README
This commit is contained in:
		
					parent
					
						
							
								67ee5b8e80
							
						
					
				
			
			
				commit
				
					
						95f3124b0d
					
				
			
		
					 41 changed files with 8549 additions and 745 deletions
				
			
		
							
								
								
									
										50
									
								
								nodes/GithubIssues/listSearch/getRepositories.ts
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										50
									
								
								nodes/GithubIssues/listSearch/getRepositories.ts
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,50 @@ | |||
| import type { | ||||
| 	ILoadOptionsFunctions, | ||||
| 	INodeListSearchItems, | ||||
| 	INodeListSearchResult, | ||||
| } from 'n8n-workflow'; | ||||
| import { githubApiRequest } from '../shared/transport'; | ||||
| 
 | ||||
| type RepositorySearchItem = { | ||||
| 	name: string; | ||||
| 	html_url: string; | ||||
| }; | ||||
| 
 | ||||
| type RepositorySearchResponse = { | ||||
| 	items: RepositorySearchItem[]; | ||||
| 	total_count: number; | ||||
| }; | ||||
| 
 | ||||
| export async function getRepositories( | ||||
| 	this: ILoadOptionsFunctions, | ||||
| 	filter?: string, | ||||
| 	paginationToken?: string, | ||||
| ): Promise<INodeListSearchResult> { | ||||
| 	const owner = this.getCurrentNodeParameter('owner', { extractValue: true }); | ||||
| 	const page = paginationToken ? +paginationToken : 1; | ||||
| 	const per_page = 100; | ||||
| 	const q = `${filter ?? ''} user:${owner} fork:true`; | ||||
| 	let responseData: RepositorySearchResponse = { | ||||
| 		items: [], | ||||
| 		total_count: 0, | ||||
| 	}; | ||||
| 
 | ||||
| 	try { | ||||
| 		responseData = await githubApiRequest.call(this, 'GET', '/search/repositories', { | ||||
| 			q, | ||||
| 			page, | ||||
| 			per_page, | ||||
| 		}); | ||||
| 	} catch { | ||||
| 		// will fail if the owner does not have any repositories
 | ||||
| 	} | ||||
| 
 | ||||
| 	const results: INodeListSearchItems[] = responseData.items.map((item: RepositorySearchItem) => ({ | ||||
| 		name: item.name, | ||||
| 		value: item.name, | ||||
| 		url: item.html_url, | ||||
| 	})); | ||||
| 
 | ||||
| 	const nextPaginationToken = page * per_page < responseData.total_count ? page + 1 : undefined; | ||||
| 	return { results, paginationToken: nextPaginationToken }; | ||||
| } | ||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue