From a5e85b7645ed095baea5de484a06527cc7467e3c Mon Sep 17 00:00:00 2001 From: Natsu Date: Mon, 17 Jun 2024 16:56:38 +0700 Subject: [PATCH] chore: Update .gitignore and add get-latest-commit API endpoint --- .gitignore | 18 ++---------------- api/.gitignore | 2 ++ api/get-latest-commit/main.js | 19 +++++++++++++++++++ api/get-latest-commit/package.json | 7 +++++++ 4 files changed, 30 insertions(+), 16 deletions(-) create mode 100644 api/.gitignore create mode 100644 api/get-latest-commit/main.js create mode 100644 api/get-latest-commit/package.json diff --git a/.gitignore b/.gitignore index b2a2b20..9b4acfc 100644 --- a/.gitignore +++ b/.gitignore @@ -1,21 +1,7 @@ -*.iml -.gradle -/local.properties -/.idea/caches -/.idea/libraries -/.idea/modules.xml -/.idea/workspace.xml -/.idea/navEditor.xml -/.idea/assetWizardSettings.xml -.DS_Store -/build -/captures -.externalNativeBuild -.cxx -local.properties +/.gradle /.idea -/.vs /app/.cxx /app/build /app/debug /app/release +/local.properties diff --git a/api/.gitignore b/api/.gitignore new file mode 100644 index 0000000..d5f19d8 --- /dev/null +++ b/api/.gitignore @@ -0,0 +1,2 @@ +node_modules +package-lock.json diff --git a/api/get-latest-commit/main.js b/api/get-latest-commit/main.js new file mode 100644 index 0000000..2de3712 --- /dev/null +++ b/api/get-latest-commit/main.js @@ -0,0 +1,19 @@ +const fetch = require('node-fetch'); + +module.exports = async (req, res) => { + const username = 'NatsumeLS'; + const repo = 'Gakumas-Localify-EN'; + const apiUrl = `https://api.github.com/repos/${username}/${repo}/commits?per_page=1`; + + try { + const response = await fetch(apiUrl); + const data = await response.json(); + const latestCommitHash = data[0].sha; + + res.setHeader('Content-Type', 'application/json'); + res.setHeader('Cache-Control', 'no-cache'); + res.status(200).json({ hash: latestCommitHash }); + } catch (error) { + res.status(500).json({ error: 'Failed to fetch latest commit hash' }); + } +}; diff --git a/api/get-latest-commit/package.json b/api/get-latest-commit/package.json new file mode 100644 index 0000000..b69fbba --- /dev/null +++ b/api/get-latest-commit/package.json @@ -0,0 +1,7 @@ +{ + "name": "get-latest-commit", + "main": "main.js", + "dependencies": { + "node-fetch": "^3.3.2" + } +}