Migrating a Local Node Script to Azure Functions using VS Code

This page summarizes the projects mentioned and recommended in the original post on dev.to

SurveyJS - Open-Source JSON Form Builder to Create Dynamic Forms Right in Your App
With SurveyJS form UI libraries, you can build and style forms in a fully-integrated drag & drop form builder, render them in your JS app, and store form submission data in any backend, inc. PHP, ASP.NET Core, and Node.js.
surveyjs.io
featured
InfluxDB - Power Real-Time Data Analytics at Scale
Get real-time insights from all types of time series data with InfluxDB. Ingest, query, and analyze billions of data points in real-time with unbounded cardinality.
www.influxdata.com
featured
  • Express

    Fast, unopinionated, minimalist web framework for node.

  • While I could easily convert the script into a Node/Express API and publish it to Azure App Service, I decided to go with Azure Functions since when you boil the script down to the basics, its job is to handle a request and return data. It doesn’t need to be constantly accessed so a consumption based model works well.

  • GitHub-API-Demo

    Discontinued [Moved to: https://github.com/DanWahlin/github-repo-stats]

  • Open my project in VS Code.

  • SurveyJS

    Open-Source JSON Form Builder to Create Dynamic Forms Right in Your App. With SurveyJS form UI libraries, you can build and style forms in a fully-integrated drag & drop form builder, render them in your JS app, and store form submission data in any backend, inc. PHP, ASP.NET Core, and Node.js.

    SurveyJS logo
  • tokens

  • const { Octokit } = require("@octokit/rest"); const { v4: uuidv4 } = require('uuid'); // Create personal access token (with repo --> public rights) at https://github.com/settings/tokens let octokit; let ownersRepos; let context; getStats(context); async function getStats(ctx) { context = ctx || { log: console.log }; // Doing this to simulate what's it like in Azure Functions ownersRepos = getRepos(); context.log(ownersRepos); const stats = []; for (const repo of ownersRepos) { octokit = new Octokit({ auth: repo.token }); const ownerRepo = { owner: repo.owner, repo: repo.repo } const clones = await getClones(ownerRepo); const forks = await getTotalForks(ownerRepo); const views = await getPageViews(ownerRepo); stats.push(getTodayRow(ownerRepo, clones, forks, views)); } context.log(stats); return stats; } function getRepos() { try { console.log(context); // Need to set env variable GITHUB_REPOS // export GITHUB_REPOS="[{ \"owner\": \"microsoft\", \"repo\": \"MicrosoftCloud\", \"token\": \"token_value\" }]" const repos = JSON.parse(process.env['GITHUB_REPOS']); context.log('Repos:', repos); return repos; } catch (e) { context.log(e); return []; } } function getTodayRow(ownerRepo, clones, forks, views) { const today = new Date(); const yesterday = new Date(today.getFullYear(), today.getMonth(), today.getDate() - 1) .toISOString().split('T')[0] + 'T00:00:00Z'; const todayClonesViewsForks ={ id: uuidv4(), timestamp: yesterday, owner: ownerRepo.owner, repo: ownerRepo.repo, clones: 0, forks: forks, views: 0 }; const todayClones = clones.clones.find(c => c.timestamp === yesterday); const todayViews = views.views.find(v => v.timestamp === yesterday); if (todayClones) { todayClonesViewsForks.clones = todayClones.count; } if (todayViews) { todayClonesViewsForks.views = todayViews.count; } return todayClonesViewsForks; } async function getClones(ownerRepo) { try { // https://docs.github.com/en/rest/metrics/traffic#get-repository-clones const { data } = await octokit.rest.repos.getClones(ownerRepo); context.log(`${ownerRepo.owner}/${ownerRepo.repo} clones:`, data.count); return data; } catch (e) { context.log(`Unable to get clones for ${ownerRepo.owner}/${ownerRepo.repo}. You probably don't have push access.`); } return 0; } async function getTotalForks(ownerRepo) { try { // https://docs.github.com/en/rest/repos/forks const { data } = await octokit.rest.repos.get(ownerRepo); const forksCount = (data) ? data.forks_count : 0; context.log(`${ownerRepo.owner}/${ownerRepo.repo} forks:`, forksCount); return forksCount } catch (e) { context.log(e); context.log(`Unable to get forks for ${ownerRepo.owner}/${ownerRepo.repo}. You probably don't have push access.`); } return 0; } async function getPageViews(ownerRepo) { try { // https://docs.github.com/en/rest/metrics/traffic#get-page-views const { data } = await await octokit.rest.repos.getViews(ownerRepo); context.log(`${ownerRepo.owner}/${ownerRepo.repo} visits:`, data.count); return data; } catch (e) { context.log(`Unable to get page views for ${ownerRepo.owner}/${ownerRepo.repo}. You probably don't have push access.`); context.log(e); } return 0; }

  • github-repo-stats

  • The code shown in this repo can be found here: https://github.com/DanWahlin/github-repo-stats.

NOTE: The number of mentions on this list indicates mentions on common posts plus user suggested alternatives. Hence, a higher number means a more popular project.

Suggest a related project

Related posts

  • Tuning de conexiones en MongoDB con Serverless Lambda

    1 project | dev.to | 10 May 2024
  • Express 5.0 – Last Push

    3 projects | news.ycombinator.com | 30 Apr 2024
  • Exploring Angular SSR: Development, API, Prefetching and Deployment

    3 projects | dev.to | 29 Apr 2024
  • Screen Sharing with WebRTC: Harnessing JavaScript for Seamless Streaming

    1 project | dev.to | 15 Mar 2024
  • Express.js: Introduction and Basic Routing

    1 project | dev.to | 15 Mar 2024