Skip to content

Instantly share code, notes, and snippets.

@liyasthomas
Created October 4, 2021 17:25
Show Gist options
  • Save liyasthomas/99dd8c244182c50f8fa392efc6fc06dd to your computer and use it in GitHub Desktop.
Save liyasthomas/99dd8c244182c50f8fa392efc6fc06dd to your computer and use it in GitHub Desktop.
import fetch from "node-fetch";
const USERNAME = "hoppscotch";
const REPOSITORY = "hoppscotch";
exports.handler = async (event) => {
switch (event.httpMethod) {
case "GET":
try {
const commit_activity_response = await fetch(
`https://api.github.com/repos/${USERNAME}/${REPOSITORY}/stats/commit_activity`
);
const commit_activity = await commit_activity_response.json();
return {
statusCode: 200,
headers: {
"Content-Type": "application/json",
"Access-Control-Allow-Origin": "*",
"Access-Control-Allow-Headers":
"Origin, X-Requested-With, Content-Type, Accept",
"Access-Control-Allow-Credentials": true,
"Access-Control-Allow-Methods": "GET",
},
body: JSON.stringify(
{
commit_activity,
},
null,
2
),
};
} catch (e) {
return { statusCode: 500, body: e.toString() };
}
default:
return { statusCode: 405, body: "Method Not Allowed" };
}
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment