commit d169a6c2b4442075d01169e4d661582081480c07 Author: adb Date: Tue Dec 8 00:45:54 2020 +0100 get matching repos diff --git a/main.js b/main.js new file mode 100644 index 0000000..40e3822 --- /dev/null +++ b/main.js @@ -0,0 +1,25 @@ +const express = require('express'); +const rest = require('superagent'); + +const giteaHost = 'git.adb.sh'; + +const app = express(); +app.get('/', function (req, res) { + res.send('Hello World'); +}); + +app.listen(3000); + +let updateRepos = setInterval(()=>{ + rest.get('https://git.adb.sh/api/v1/repos/search?q=git.adb.sh').then(res=>{ + console.log(res.text); + let content = JSON.parse(res.text); + content.data.forEach(repo=>{ + if (!repo.name.match(/^(.*).git.adb.sh/)) return; //matches domain? + let namePattern = new RegExp(`^(.*.)|()${repo.owner.username}.${giteaHost}`); + if (!repo.name.match(namePattern)) return; //matches owner? + console.log(`found => ${repo.owner.username}.${giteaHost}`) + + }); + }).catch(console.error); +},1000); \ No newline at end of file diff --git a/package.json b/package.json new file mode 100644 index 0000000..83ec1f6 --- /dev/null +++ b/package.json @@ -0,0 +1,16 @@ +{ + "name": "gitea-repo-host", + "version": "1.0.0", + "description": "", + "main": "main.js", + "scripts": { + "test": "echo \"Error: no test specified\" && exit 1" + }, + "keywords": [], + "author": "", + "license": "ISC", + "dependencies": { + "express": "^4.17.1", + "superagent": "^6.1.0" + } +}