Merge branch 'main' into andrew

This commit is contained in:
2025-05-06 21:24:38 -04:00
33 changed files with 1579 additions and 1301 deletions
+208 -208
View File
@@ -1,234 +1,234 @@
{
"env": {
"node": true,
"browser": true,
"es2021": true
},
"extends": [
// "eslint:recommended",
"prettier"
],
"parserOptions": {
"sourceType": "module",
"ecmaVersion": 2022
},
"rules": {
// Possible Errors (overrides from recommended set)
// {
// "env": {
// "node": true,
// "browser": true,
// "es2021": true
// },
// "extends": [
// // "eslint:recommended",
// "prettier"
// ],
// "parserOptions": {
// "sourceType": "module",
// "ecmaVersion": 2022
// },
// "rules": {
// // Possible Errors (overrides from recommended set)
// "no-extra-parens": "error",
"no-unexpected-multiline": "error",
// // "no-extra-parens": "error",
// "no-unexpected-multiline": "error",
// All JSDoc comments must be valid
// // All JSDoc comments must be valid
"valid-jsdoc": [ "error", {
"requireReturn": true,
"requireReturnDescription": true,
"requireParamDescription": true,
"prefer": {
"return": "returns"
}
}],
// "valid-jsdoc": [ "error", {
// "requireReturn": true,
// "requireReturnDescription": true,
// "requireParamDescription": true,
// "prefer": {
// "return": "returns"
// }
// }],
// Best Practices
// // Best Practices
// Allowed a getter without setter, but all setters require getters
// // Allowed a getter without setter, but all setters require getters
"accessor-pairs": [ "error", {
"getWithoutSet": false,
"setWithoutGet": true
}],
"block-scoped-var": "warn",
"consistent-return": "error",
"curly": "error",
// "default-case": "warn",
// "accessor-pairs": [ "error", {
// "getWithoutSet": false,
// "setWithoutGet": true
// }],
// "block-scoped-var": "warn",
// "consistent-return": "error",
// "curly": "error",
// // "default-case": "warn",
// the dot goes with the property when doing multiline
// // the dot goes with the property when doing multiline
// "dot-location": [ "warn", "property" ],
// "dot-notation": "warn",
// "eqeqeq": [ "error", "smart" ],
// "guard-for-in": "warn",
"no-alert": "error",
"no-caller": "error",
// "no-case-declarations": "warn",
// "no-div-regex": "warn",
// "no-else-return": "warn",
// "no-empty-label": "warn",
// "no-empty-pattern": "warn",
// "no-eq-null": "warn",
// "no-eval": "error",
// "no-extend-native": "error",
// "no-extra-bind": "warn",
// "no-floating-decimal": "warn",
// "no-implicit-coercion": [ "warn", {
// "boolean": true,
// "number": true,
// "string": true
// }],
// "no-implied-eval": "error",
// "no-invalid-this": "error",
// "no-iterator": "error",
// "no-labels": "warn",
// "no-lone-blocks": "warn",
// "no-loop-func": "error",
// "no-magic-numbers": "warn",
// "no-multi-spaces": "error",
// "no-multi-str": "warn",
// "no-native-reassign": "error",
// "no-new-func": "error",
// "no-new-wrappers": "error",
// "no-new": "error",
// "no-octal-escape": "error",
// "no-param-reassign": "error",
// "no-process-env": "warn",
// "no-proto": "error",
// "no-redeclare": "error",
// "no-return-assign": "error",
// "no-script-url": "error",
// "no-self-compare": "error",
// "no-throw-literal": "error",
// "no-unused-expressions": "error",
// "no-useless-call": "error",
// "no-useless-concat": "error",
// "no-void": "warn",
// // "dot-location": [ "warn", "property" ],
// // "dot-notation": "warn",
// // "eqeqeq": [ "error", "smart" ],
// // "guard-for-in": "warn",
// "no-alert": "error",
// "no-caller": "error",
// // "no-case-declarations": "warn",
// // "no-div-regex": "warn",
// // "no-else-return": "warn",
// // "no-empty-label": "warn",
// // "no-empty-pattern": "warn",
// // "no-eq-null": "warn",
// // "no-eval": "error",
// // "no-extend-native": "error",
// // "no-extra-bind": "warn",
// // "no-floating-decimal": "warn",
// // "no-implicit-coercion": [ "warn", {
// // "boolean": true,
// // "number": true,
// // "string": true
// // }],
// // "no-implied-eval": "error",
// // "no-invalid-this": "error",
// // "no-iterator": "error",
// // "no-labels": "warn",
// // "no-lone-blocks": "warn",
// // "no-loop-func": "error",
// // "no-magic-numbers": "warn",
// // "no-multi-spaces": "error",
// // "no-multi-str": "warn",
// // "no-native-reassign": "error",
// // "no-new-func": "error",
// // "no-new-wrappers": "error",
// // "no-new": "error",
// // "no-octal-escape": "error",
// // "no-param-reassign": "error",
// // "no-process-env": "warn",
// // "no-proto": "error",
// // "no-redeclare": "error",
// // "no-return-assign": "error",
// // "no-script-url": "error",
// // "no-self-compare": "error",
// // "no-throw-literal": "error",
// // "no-unused-expressions": "error",
// // "no-useless-call": "error",
// // "no-useless-concat": "error",
// // "no-void": "warn",
// Produce warnings when something is commented as TODO or FIXME
// // Produce warnings when something is commented as TODO or FIXME
"no-warning-comments": [ "warn", {
"terms": [ "TODO", "FIXME" ],
"location": "start"
}],
"no-with": "warn",
"radix": "warn",
// "vars-on-top": "error",
// "no-warning-comments": [ "warn", {
// "terms": [ "TODO", "FIXME" ],
// "location": "start"
// }],
// "no-with": "warn",
// "radix": "warn",
// // "vars-on-top": "error",
// Enforces the style of wrapped functions
// "wrap-iife": [ "error", "outside" ],
// "yoda": "error",
// // Enforces the style of wrapped functions
// // "wrap-iife": [ "error", "outside" ],
// // "yoda": "error",
// Strict Mode - for ES6, never use strict.
// "strict": [ "error", "never" ],
// // Strict Mode - for ES6, never use strict.
// // "strict": [ "error", "never" ],
// Variables
// // Variables
// "init-declarations": [ "error", "always" ],
// "no-catch-shadow": "warn",
"no-delete-var": "error",
// "no-label-var": "error",
// "no-shadow-restricted-names": "error",
// "no-shadow": "warn",
// // "init-declarations": [ "error", "always" ],
// // "no-catch-shadow": "warn",
// "no-delete-var": "error",
// // "no-label-var": "error",
// // "no-shadow-restricted-names": "error",
// // "no-shadow": "warn",
// We require all vars to be initialized (see init-declarations)
// If we NEED a var to be initialized to undefined, it needs to be explicit
// // We require all vars to be initialized (see init-declarations)
// // If we NEED a var to be initialized to undefined, it needs to be explicit
"no-undef-init": "off",
"no-undef": "error",
"no-undefined": "off",
"no-unused-vars": "warn",
// "no-undef-init": "off",
// "no-undef": "error",
// "no-undefined": "off",
// "no-unused-vars": "warn",
// Disallow hoisting - let & const don't allow hoisting anyhow
// // Disallow hoisting - let & const don't allow hoisting anyhow
"no-use-before-define": "error",
// "no-use-before-define": "error",
// Node.js and CommonJS
// // Node.js and CommonJS
// "callback-return": [ "warn", [ "callback", "next" ]],
// "global-require": "error",
// "handle-callback-err": "warn",
// "no-mixed-requires": "warn",
// "no-new-require": "error",
// // "callback-return": [ "warn", [ "callback", "next" ]],
// // "global-require": "error",
// // "handle-callback-err": "warn",
// // "no-mixed-requires": "warn",
// // "no-new-require": "error",
// Use path.concat instead
// // Use path.concat instead
// "no-path-concat": "error",
// "no-process-exit": "error",
// "no-restricted-modules": "off",
// "no-sync": "warn",
// // "no-path-concat": "error",
// // "no-process-exit": "error",
// // "no-restricted-modules": "off",
// // "no-sync": "warn",
// ECMAScript 6 support
// // ECMAScript 6 support
// "arrow-body-style": [ "error", "always" ],
// "arrow-parens": [ "error", "always" ],
// "arrow-spacing": [ "error", { "before": true, "after": true }],
"constructor-super": "error",
// "generator-star-spacing": [ "error", "before" ],
// "no-arrow-condition": "error",
"no-class-assign": "error",
"no-const-assign": "error",
"no-dupe-class-members": "error",
"no-this-before-super": "error",
// "no-var": "warn",
"object-shorthand": [ "warn" ],
// "prefer-arrow-callback": "warn",
// "prefer-spread": "warn",
// "prefer-template": "warn",
// "require-yield": "error",
// // "arrow-body-style": [ "error", "always" ],
// // "arrow-parens": [ "error", "always" ],
// // "arrow-spacing": [ "error", { "before": true, "after": true }],
// "constructor-super": "error",
// // "generator-star-spacing": [ "error", "before" ],
// // "no-arrow-condition": "error",
// "no-class-assign": "error",
// "no-const-assign": "error",
// "no-dupe-class-members": "error",
// "no-this-before-super": "error",
// // "no-var": "warn",
// "object-shorthand": [ "warn" ],
// // "prefer-arrow-callback": "warn",
// // "prefer-spread": "warn",
// // "prefer-template": "warn",
// // "require-yield": "error",
// Stylistic - everything here is a warning because of style.
// // Stylistic - everything here is a warning because of style.
// "array-bracket-spacing": [ "warn", "always" ],
// "block-spacing": [ "warn", "always" ],
// "brace-style": [ "warn", "1tbs", { "allowSingleLine": false } ],
// "camelcase": "warn",
// "comma-spacing": [ "warn", { "before": false, "after": true } ],
// "comma-style": [ "warn", "last" ],
// "computed-property-spacing": [ "warn", "never" ],
// "consistent-this": [ "warn", "self" ],
// "eol-last": "warn",
// "func-names": "warn",
// "func-style": [ "warn", "declaration" ],
// "id-length": [ "warn", { "min": 2, "max": 32 } ],
// "indent": [ "warn", 4 ],
// "jsx-quotes": [ "warn", "prefer-double" ],
// "linebreak-style": [ "warn", "unix" ],
// "lines-around-comment": [ "warn", { "beforeBlockComment": true } ],
// "max-depth": [ "warn", 8 ],
// "max-len": [ "warn", 132 ],
// "max-nested-callbacks": [ "warn", 8 ],
// "max-params": [ "warn", 8 ],
// "new-cap": "warn",
// "new-parens": "warn",
// "no-array-constructor": "warn",
// "no-bitwise": "off",
// "no-continue": "off",
// "no-inline-comments": "off",
// "no-lonely-if": "warn",
"no-mixed-spaces-and-tabs": "warn",
"no-multiple-empty-lines": "warn",
"no-negated-condition": "warn",
// "no-nested-ternary": "warn",
// "no-new-object": "warn",
// "no-plusplus": "off",
// "no-spaced-func": "warn",
// "no-ternary": "off",
// "no-trailing-spaces": "warn",
// "no-underscore-dangle": "warn",
"no-unneeded-ternary": "warn",
// "object-curly-spacing": [ "warn", "always" ],
// "one-var": "off",
// "operator-assignment": [ "warn", "never" ],
// "operator-linebreak": [ "warn", "after" ],
// "padded-blocks": [ "warn", "never" ],
// "quote-props": [ "warn", "consistent-as-needed" ],
// "quotes": [ "warn", "single" ],
"require-jsdoc": [ "warn", {
"require": {
"FunctionDeclaration": true,
"MethodDefinition": true,
"ClassDeclaration": false
}
}],
// "semi-spacing": [ "warn", { "before": false, "after": true }],
// "semi": [ "error", "always" ],
// "sort-vars": "off",
"keyword-spacing": ["error", { "before": true, "after": true }]
// "space-before-blocks": [ "warn", "always" ],
// "space-before-function-paren": [ "warn", "never" ],
// "space-in-parens": [ "warn", "never" ],
// "space-infix-ops": [ "warn", { "int32Hint": true } ],
// "space-return-throw-case": "error",
// "space-unary-ops": "error",
// "spaced-comment": [ "warn", "always" ],
// "wrap-regex": "warn"
}
}
// // "array-bracket-spacing": [ "warn", "always" ],
// // "block-spacing": [ "warn", "always" ],
// // "brace-style": [ "warn", "1tbs", { "allowSingleLine": false } ],
// // "camelcase": "warn",
// // "comma-spacing": [ "warn", { "before": false, "after": true } ],
// // "comma-style": [ "warn", "last" ],
// // "computed-property-spacing": [ "warn", "never" ],
// // "consistent-this": [ "warn", "self" ],
// // "eol-last": "warn",
// // "func-names": "warn",
// // "func-style": [ "warn", "declaration" ],
// // "id-length": [ "warn", { "min": 2, "max": 32 } ],
// // "indent": [ "warn", 4 ],
// // "jsx-quotes": [ "warn", "prefer-double" ],
// // "linebreak-style": [ "warn", "unix" ],
// // "lines-around-comment": [ "warn", { "beforeBlockComment": true } ],
// // "max-depth": [ "warn", 8 ],
// // "max-len": [ "warn", 132 ],
// // "max-nested-callbacks": [ "warn", 8 ],
// // "max-params": [ "warn", 8 ],
// // "new-cap": "warn",
// // "new-parens": "warn",
// // "no-array-constructor": "warn",
// // "no-bitwise": "off",
// // "no-continue": "off",
// // "no-inline-comments": "off",
// // "no-lonely-if": "warn",
// "no-mixed-spaces-and-tabs": "warn",
// "no-multiple-empty-lines": "warn",
// "no-negated-condition": "warn",
// // "no-nested-ternary": "warn",
// // "no-new-object": "warn",
// // "no-plusplus": "off",
// // "no-spaced-func": "warn",
// // "no-ternary": "off",
// // "no-trailing-spaces": "warn",
// // "no-underscore-dangle": "warn",
// "no-unneeded-ternary": "warn",
// // "object-curly-spacing": [ "warn", "always" ],
// // "one-var": "off",
// // "operator-assignment": [ "warn", "never" ],
// // "operator-linebreak": [ "warn", "after" ],
// // "padded-blocks": [ "warn", "never" ],
// // "quote-props": [ "warn", "consistent-as-needed" ],
// // "quotes": [ "warn", "single" ],
// "require-jsdoc": [ "warn", {
// "require": {
// "FunctionDeclaration": true,
// "MethodDefinition": true,
// "ClassDeclaration": false
// }
// }],
// // "semi-spacing": [ "warn", { "before": false, "after": true }],
// // "semi": [ "error", "always" ],
// // "sort-vars": "off",
// "keyword-spacing": ["error", { "before": true, "after": true }]
// // "space-before-blocks": [ "warn", "always" ],
// // "space-before-function-paren": [ "warn", "never" ],
// // "space-in-parens": [ "warn", "never" ],
// // "space-infix-ops": [ "warn", { "int32Hint": true } ],
// // "space-return-throw-case": "error",
// // "space-unary-ops": "error",
// // "spaced-comment": [ "warn", "always" ],
// // "wrap-regex": "warn"
// }
// }
+1 -1
View File
@@ -29,7 +29,7 @@ jobs:
steps:
- name: Checkout repository
uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v4.1.6
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
+1 -1
View File
@@ -4,7 +4,7 @@ file = open('./vercel.json', 'r')
str = file.read()
file = open('./vercel.json', 'w')
str = str.replace('"maxDuration": 10', '"maxDuration": 30')
str = str.replace('"maxDuration": 10', '"maxDuration": 15')
file.write(str)
file.close()
+2 -2
View File
@@ -10,10 +10,10 @@ jobs:
if: github.repository == 'anuraghazra/github-readme-stats'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v4.1.6
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
- name: Deployment Prep
run: python ./.github/workflows/deploy-prep.py
- uses: stefanzweifel/git-auto-commit-action@8621497c8c39c72f3e2a999a26b4ca1b5058a842 # v5.0.1
- uses: stefanzweifel/git-auto-commit-action@b863ae1933cb653a53c021fe36dbb774e1fb9403 # v5.2.0
with:
branch: vercel
create_branch: true
+2 -2
View File
@@ -17,10 +17,10 @@ jobs:
node-version: [18.x]
steps:
- uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v4.1.6
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
- name: Setup Node
uses: actions/setup-node@60edb5dd545a775178f52524783378180af0d1f8 # v4.0.2
uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4.4.0
with:
node-version: ${{ matrix.node-version }}
cache: npm
+1 -1
View File
@@ -27,7 +27,7 @@ jobs:
runs-on: ubuntu-latest
steps:
# NOTE: Retrieve issue templates.
- uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v4.1.6
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
- name: Run empty issues closer action
uses: rickstaa/empty-issues-closer-action@e96914613221511279ca25f50fd4acc85e331d99 # v1.1.74
+2 -2
View File
@@ -29,10 +29,10 @@ jobs:
node-version: [18.x]
steps:
- uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v4.1.6
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
- name: Setup Node
uses: actions/setup-node@60edb5dd545a775178f52524783378180af0d1f8 # v4.0.2
uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4.4.0
with:
node-version: ${{ matrix.node-version }}
cache: npm
+3 -3
View File
@@ -22,12 +22,12 @@ jobs:
steps:
- name: "Checkout code"
uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v4.1.6
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
with:
persist-credentials: false
- name: "Run analysis"
uses: ossf/scorecard-action@dc50aa9510b46c811795eb24b2f1ba02a914e534 # v2.3.3
uses: ossf/scorecard-action@f49aabe0b5af0936a0987cfb85d86b75731b0186 # v2.4.1
with:
results_file: results.sarif
results_format: sarif
@@ -36,7 +36,7 @@ jobs:
# Upload the results as artifacts (optional). Commenting out will disable uploads of run results in SARIF
# format to the repository Actions tab.
- name: "Upload artifact"
uses: actions/upload-artifact@65462800fd760344b1a7b4382951275a0abb4808 # v4.3.3
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
with:
name: SARIF file
path: results.sarif
+3 -3
View File
@@ -30,15 +30,15 @@ jobs:
node-version: [18.x]
steps:
- uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v4.1.6
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
- name: Setup Node
uses: actions/setup-node@60edb5dd545a775178f52524783378180af0d1f8 # v4.0.2
uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4.4.0
with:
node-version: ${{ matrix.node-version }}
cache: npm
- uses: bahmutov/npm-install@e5c7e14408aa6089501de32bd16123b41738047e # v1.10.2
- uses: bahmutov/npm-install@6bbff949458c1dd99b20e185cee8c4d6fcf1212a # v1.10.9
with:
useLockFile: false
+1 -1
View File
@@ -23,7 +23,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v4.1.6
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
- name: Cleanup
run: |
+3 -3
View File
@@ -36,15 +36,15 @@ jobs:
node-version: [18.x]
steps:
- uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v4.1.6
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
- name: Setup Node
uses: actions/setup-node@60edb5dd545a775178f52524783378180af0d1f8 # v4.0.2
uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4.4.0
with:
node-version: ${{ matrix.node-version }}
cache: npm
- uses: bahmutov/npm-install@e5c7e14408aa6089501de32bd16123b41738047e # v1.10.2
- uses: bahmutov/npm-install@6bbff949458c1dd99b20e185cee8c4d6fcf1212a # v1.10.9
with:
useLockFile: false
+2 -2
View File
@@ -18,10 +18,10 @@ jobs:
node-version: [18.x]
steps:
- uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v4.1.6
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
- name: Setup Node
uses: actions/setup-node@60edb5dd545a775178f52524783378180af0d1f8 # v4.0.2
uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4.4.0
with:
node-version: ${{ matrix.node-version }}
cache: npm
+3 -3
View File
@@ -36,10 +36,10 @@ jobs:
node-version: [18.x]
steps:
- uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v4.1.6
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
- name: Setup Node
uses: actions/setup-node@60edb5dd545a775178f52524783378180af0d1f8 # v4.0.2
uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4.4.0
with:
node-version: ${{ matrix.node-version }}
cache: npm
@@ -53,7 +53,7 @@ jobs:
run: npm run generate-langs-json
- name: Create Pull Request if upstream language file is changed
uses: peter-evans/create-pull-request@6d6857d36972b65feb161a90e484f2984215f83e # v6.0.5
uses: peter-evans/create-pull-request@271a8d0340265f705b14b6d32b9829c1cb33d45e # v7.0.8
with:
commit-message: "refactor: update languages JSON"
branch: "update_langs/patch"
+4 -19
View File
@@ -42,32 +42,17 @@ export default async (req, res) => {
const gistData = await fetchGist(id);
let cacheSeconds = clampValue(
parseInt(cache_seconds || CONSTANTS.SIX_HOURS, 10),
CONSTANTS.SIX_HOURS,
CONSTANTS.ONE_DAY,
parseInt(cache_seconds || CONSTANTS.TWO_DAY, 10),
CONSTANTS.TWO_DAY,
CONSTANTS.SIX_DAY,
);
cacheSeconds = process.env.CACHE_SECONDS
? parseInt(process.env.CACHE_SECONDS, 10) || cacheSeconds
: cacheSeconds;
/*
if star count & fork count is over 1k then we are kFormating the text
and if both are zero we are not showing the stats
so we can just make the cache longer, since there is no need to frequent updates
*/
const stars = gistData.starsCount;
const forks = gistData.forksCount;
const isBothOver1K = stars > 1000 && forks > 1000;
const isBothUnder1 = stars < 1 && forks < 1;
if (!cache_seconds && (isBothOver1K || isBothUnder1)) {
cacheSeconds = CONSTANTS.SIX_HOURS;
}
res.setHeader(
"Cache-Control",
`max-age=${
cacheSeconds / 2
}, s-maxage=${cacheSeconds}, stale-while-revalidate=${CONSTANTS.ONE_DAY}`,
`max-age=${cacheSeconds}, s-maxage=${cacheSeconds}`,
);
return res.send(
+3 -5
View File
@@ -79,8 +79,8 @@ export default async (req, res) => {
let cacheSeconds = clampValue(
parseInt(cache_seconds || CONSTANTS.CARD_CACHE_SECONDS, 10),
CONSTANTS.SIX_HOURS,
CONSTANTS.ONE_DAY,
CONSTANTS.TWELVE_HOURS,
CONSTANTS.TWO_DAY,
);
cacheSeconds = process.env.CACHE_SECONDS
? parseInt(process.env.CACHE_SECONDS, 10) || cacheSeconds
@@ -88,9 +88,7 @@ export default async (req, res) => {
res.setHeader(
"Cache-Control",
`max-age=${
cacheSeconds / 2
}, s-maxage=${cacheSeconds}, stale-while-revalidate=${CONSTANTS.ONE_DAY}`,
`max-age=${cacheSeconds}, s-maxage=${cacheSeconds}, stale-while-revalidate=${CONSTANTS.ONE_DAY}`,
);
return res.send(
+3 -18
View File
@@ -57,32 +57,17 @@ export default async (req, res) => {
const repoData = await fetchRepo(username, repo);
let cacheSeconds = clampValue(
parseInt(cache_seconds || CONSTANTS.CARD_CACHE_SECONDS, 10),
CONSTANTS.SIX_HOURS,
parseInt(cache_seconds || CONSTANTS.PIN_CARD_CACHE_SECONDS, 10),
CONSTANTS.ONE_DAY,
CONSTANTS.TEN_DAY,
);
cacheSeconds = process.env.CACHE_SECONDS
? parseInt(process.env.CACHE_SECONDS, 10) || cacheSeconds
: cacheSeconds;
/*
if star count & fork count is over 1k then we are kFormating the text
and if both are zero we are not showing the stats
so we can just make the cache longer, since there is no need to frequent updates
*/
const stars = repoData.starCount;
const forks = repoData.forkCount;
const isBothOver1K = stars > 1000 && forks > 1000;
const isBothUnder1 = stars < 1 && forks < 1;
if (!cache_seconds && (isBothOver1K || isBothUnder1)) {
cacheSeconds = CONSTANTS.SIX_HOURS;
}
res.setHeader(
"Cache-Control",
`max-age=${
cacheSeconds / 2
}, s-maxage=${cacheSeconds}, stale-while-revalidate=${CONSTANTS.ONE_DAY}`,
`max-age=${cacheSeconds}, s-maxage=${cacheSeconds}`,
);
return res.send(
+3
View File
@@ -91,6 +91,9 @@ export default async (req, res) => {
try {
await retryer(uptimeFetcher, {});
} catch (err) {
// Resolve eslint no-unused-vars
err;
PATsValid = false;
}
+4 -8
View File
@@ -1,7 +1,6 @@
import { renderTopLanguages } from "../src/cards/top-languages-card.js";
import { blacklist } from "../src/common/blacklist.js";
import {
clampValue,
CONSTANTS,
parseArray,
parseBoolean,
@@ -70,10 +69,9 @@ export default async (req, res) => {
count_weight,
);
let cacheSeconds = clampValue(
parseInt(cache_seconds || CONSTANTS.CARD_CACHE_SECONDS, 10),
CONSTANTS.SIX_HOURS,
CONSTANTS.ONE_DAY,
let cacheSeconds = parseInt(
cache_seconds || CONSTANTS.TOP_LANGS_CACHE_SECONDS,
10,
);
cacheSeconds = process.env.CACHE_SECONDS
? parseInt(process.env.CACHE_SECONDS, 10) || cacheSeconds
@@ -81,9 +79,7 @@ export default async (req, res) => {
res.setHeader(
"Cache-Control",
`max-age=${
cacheSeconds / 2
}, s-maxage=${cacheSeconds}, stale-while-revalidate=${CONSTANTS.ONE_DAY}`,
`max-age=${cacheSeconds / 2}, s-maxage=${cacheSeconds}`,
);
return res.send(
+1 -1
View File
@@ -54,7 +54,7 @@ export default async (req, res) => {
let cacheSeconds = clampValue(
parseInt(cache_seconds || CONSTANTS.CARD_CACHE_SECONDS, 10),
CONSTANTS.SIX_HOURS,
CONSTANTS.ONE_DAY,
CONSTANTS.TWO_DAY,
);
cacheSeconds = process.env.CACHE_SECONDS
? parseInt(process.env.CACHE_SECONDS, 10) || cacheSeconds
+83
View File
@@ -0,0 +1,83 @@
import globals from "globals";
import path from "node:path";
import { fileURLToPath } from "node:url";
import js from "@eslint/js";
import { FlatCompat } from "@eslint/eslintrc";
import jsdoc from "eslint-plugin-jsdoc";
const __filename = fileURLToPath(import.meta.url);
const __dirname = path.dirname(__filename);
const compat = new FlatCompat({
baseDirectory: __dirname,
recommendedConfig: js.configs.recommended,
allConfig: js.configs.all,
});
export default [
...compat.extends("prettier"),
{
languageOptions: {
globals: {
...globals.node,
...globals.browser,
},
ecmaVersion: 2022,
sourceType: "module",
},
plugins: {
jsdoc,
},
rules: {
"no-unexpected-multiline": "error",
"accessor-pairs": [
"error",
{
getWithoutSet: false,
setWithoutGet: true,
},
],
"block-scoped-var": "warn",
"consistent-return": "error",
curly: "error",
"no-alert": "error",
"no-caller": "error",
"no-warning-comments": [
"warn",
{
terms: ["TODO", "FIXME"],
location: "start",
},
],
"no-with": "warn",
radix: "warn",
"no-delete-var": "error",
"no-undef-init": "off",
"no-undef": "error",
"no-undefined": "off",
"no-unused-vars": "warn",
"no-use-before-define": "error",
"constructor-super": "error",
"no-class-assign": "error",
"no-const-assign": "error",
"no-dupe-class-members": "error",
"no-this-before-super": "error",
"object-shorthand": ["warn"],
"no-mixed-spaces-and-tabs": "warn",
"no-multiple-empty-lines": "warn",
"no-negated-condition": "warn",
"no-unneeded-ternary": "warn",
"keyword-spacing": [
"error",
{
before: true,
after: true,
},
],
"jsdoc/require-returns": "warn",
"jsdoc/require-returns-description": "warn",
"jsdoc/require-param-description": "warn",
"jsdoc/require-jsdoc": "warn",
},
},
];
+1157 -845
View File
File diff suppressed because it is too large Load Diff
+15 -11
View File
@@ -36,29 +36,33 @@
"author": "Anurag Hazra",
"license": "MIT",
"devDependencies": {
"@actions/core": "^1.10.1",
"@actions/core": "^1.11.1",
"@actions/github": "^6.0.0",
"@testing-library/dom": "^10.1.0",
"@testing-library/jest-dom": "^6.4.5",
"@eslint/eslintrc": "^3.3.1",
"@eslint/js": "^9.25.1",
"@testing-library/dom": "^10.4.0",
"@testing-library/jest-dom": "^6.6.3",
"@uppercod/css-to-object": "^1.1.1",
"axios-mock-adapter": "^1.22.0",
"axios-mock-adapter": "^2.1.0",
"color-contrast-checker": "^2.1.0",
"eslint": "^8.57.0",
"eslint-config-prettier": "^9.1.0",
"eslint": "^9.25.1",
"eslint-config-prettier": "^10.1.2",
"eslint-plugin-jsdoc": "^50.6.11",
"globals": "^16.0.0",
"hjson": "^3.2.2",
"husky": "^9.0.11",
"husky": "^9.1.7",
"jest": "^29.7.0",
"jest-bench": "^29.7.1",
"jest-environment-jsdom": "^29.7.0",
"js-yaml": "^4.1.0",
"lint-staged": "^15.2.2",
"lint-staged": "^15.5.1",
"lodash.snakecase": "^4.1.1",
"parse-diff": "^0.11.1",
"prettier": "^3.2.5"
"prettier": "^3.5.3"
},
"dependencies": {
"axios": "^1.7.1",
"dotenv": "^16.4.5",
"axios": "^1.9.0",
"dotenv": "^16.5.0",
"emoji-name-map": "^1.2.8",
"github-username-regex": "^1.0.0",
"upgrade": "^1.1.0",
+3
View File
@@ -20,6 +20,9 @@ export const getRepoInfo = (ctx) => {
repo: ctx.repo.repo,
};
} catch (error) {
// Resolve eslint no-unused-vars
error;
return {
owner: OWNER,
repo: REPO,
+3
View File
@@ -332,6 +332,9 @@ const parseJSON = (json) => {
);
}
} catch (error) {
// Resolve eslint no-unused-vars
error;
// Remove trailing commas (if any).
let parsedJson = json.replace(/(,\s*})/g, "}");
+7 -1
View File
@@ -1,4 +1,10 @@
const blacklist = ["renovate-bot", "technote-space", "sw-yx"];
const blacklist = [
"renovate-bot",
"technote-space",
"sw-yx",
"YourUsername",
"[YourUsername]",
];
export { blacklist };
export default blacklist;
+45 -3
View File
@@ -22,6 +22,7 @@
"Alpine Abuild": "#0D597F",
"Altium Designer": "#A89663",
"AngelScript": "#C7D7DC",
"Answer Set Programming": "#A9CC29",
"Ant Build System": "#A9157E",
"Antlers": "#ff269e",
"ApacheConf": "#d12127",
@@ -39,7 +40,9 @@
"AutoIt": "#1C3552",
"Avro IDL": "#0040FF",
"Awk": "#c30e9b",
"B4X": "#00e4ff",
"BASIC": "#ff0000",
"BQN": "#2b7067",
"Ballerina": "#FF5000",
"Batchfile": "#C1F12E",
"Beef": "#a52f4e",
@@ -68,15 +71,18 @@
"CMake": "#DA3434",
"COLLADA": "#F1A42B",
"CSON": "#244776",
"CSS": "#563d7c",
"CSS": "#663399",
"CSV": "#237346",
"CUE": "#5886E1",
"CWeb": "#00007a",
"Cabal Config": "#483465",
"Caddyfile": "#22b638",
"Cadence": "#00ef8b",
"Cairo": "#ff4a48",
"Cairo Zero": "#ff4a48",
"CameLIGO": "#3be133",
"Cap'n Proto": "#c42727",
"Carbon": "#222222",
"Ceylon": "#dfa535",
"Chapel": "#8dc63f",
"ChucK": "#3f8000",
@@ -97,13 +103,13 @@
"Common Lisp": "#3fb68b",
"Common Workflow Language": "#B5314C",
"Component Pascal": "#B0CE4E",
"Coq": "#d0b68c",
"Crystal": "#000100",
"Csound": "#1a1a1a",
"Csound Document": "#1a1a1a",
"Csound Score": "#1a1a1a",
"Cuda": "#3A4E3A",
"Curry": "#531242",
"Cylc": "#00b3fd",
"Cypher": "#34c0eb",
"Cython": "#fedf5b",
"D": "#ba595e",
@@ -120,6 +126,7 @@
"Dockerfile": "#384d54",
"Dogescript": "#cca760",
"Dotenv": "#e5d559",
"Dune": "#89421e",
"Dylan": "#6c616e",
"E": "#ccce35",
"ECL": "#8a1267",
@@ -145,6 +152,7 @@
"F#": "#b845fc",
"F*": "#572e30",
"FIGlet Font": "#FFDDBB",
"FIRRTL": "#2f632f",
"FLUX": "#88ccff",
"Factor": "#636746",
"Fancy": "#7b9db4",
@@ -156,7 +164,7 @@
"Forth": "#341708",
"Fortran": "#4d41b1",
"Fortran Free Form": "#4d41b1",
"FreeBasic": "#141AC9",
"FreeBASIC": "#141AC9",
"FreeMarker": "#0050b2",
"Frege": "#00cafe",
"Futhark": "#5f021f",
@@ -205,6 +213,7 @@
"Groovy Server Pages": "#4298b8",
"HAProxy": "#106da9",
"HCL": "#844FBA",
"HIP": "#4F3A4F",
"HLSL": "#aace60",
"HOCON": "#9ff8ee",
"HTML": "#e34c26",
@@ -219,6 +228,7 @@
"Haml": "#ece2a9",
"Handlebars": "#f7931e",
"Harbour": "#0e60e3",
"Hare": "#9d7424",
"Haskell": "#5e5086",
"Haxe": "#df7900",
"HiveQL": "#dce200",
@@ -228,6 +238,7 @@
"IDL": "#a3522f",
"IGOR Pro": "#0000cc",
"INI": "#d1dbe0",
"ISPC": "#2D68B1",
"Idris": "#b30000",
"Ignore List": "#000000",
"ImageJ Macro": "#99AAFF",
@@ -246,11 +257,13 @@
"JSON5": "#267CB9",
"JSONLD": "#0c479c",
"JSONiq": "#40d47e",
"Jai": "#ab8b4b",
"Janet": "#0886a5",
"Jasmin": "#d03600",
"Java": "#b07219",
"Java Properties": "#2A6277",
"Java Server Pages": "#2A6277",
"Java Template Engine": "#2A6277",
"JavaScript": "#f1e05a",
"JavaScript+ERB": "#f1e05a",
"Jest Snapshot": "#15c213",
@@ -261,8 +274,10 @@
"Jolie": "#843179",
"Jsonnet": "#0064bd",
"Julia": "#a270ba",
"Julia REPL": "#a270ba",
"Jupyter Notebook": "#DA5B0B",
"Just": "#384d54",
"KDL": "#ffb3b3",
"KRL": "#28430A",
"Kaitai Struct": "#773b37",
"KakouneScript": "#6f8042",
@@ -270,6 +285,7 @@
"KiCad Layout": "#2f4aab",
"KiCad Legacy Layout": "#2f4aab",
"KiCad Schematic": "#2f4aab",
"Koka": "#215166",
"Kotlin": "#A97BFF",
"LFE": "#4C3023",
"LLVM": "#185619",
@@ -287,10 +303,13 @@
"Literate Agda": "#315665",
"Literate CoffeeScript": "#244776",
"Literate Haskell": "#5e5086",
"LiveCode Script": "#0c5ba5",
"LiveScript": "#499886",
"Logtalk": "#295b9a",
"LookML": "#652B81",
"Lua": "#000080",
"Luau": "#00A2FF",
"M3U": "#179C7D",
"MATLAB": "#e16737",
"MAXScript": "#00a6a6",
"MDX": "#fcb32c",
@@ -311,6 +330,7 @@
"Meson": "#007800",
"Metal": "#8f14e9",
"MiniYAML": "#ff1111",
"MiniZinc": "#06a9e6",
"Mint": "#02b046",
"Mirah": "#c7a938",
"Modelica": "#de1d31",
@@ -318,12 +338,14 @@
"Modula-3": "#223388",
"Mojo": "#ff4c1f",
"Monkey C": "#8D6747",
"MoonBit": "#b92381",
"MoonScript": "#ff4585",
"Motoko": "#fbb03b",
"Motorola 68K Assembly": "#005daa",
"Move": "#4a137a",
"Mustache": "#724b3b",
"NCL": "#28431f",
"NMODL": "#00356B",
"NPM Config": "#cb3837",
"NWScript": "#111522",
"Nasal": "#1d2c4e",
@@ -338,6 +360,7 @@
"Nim": "#ffc200",
"Nit": "#009917",
"Nix": "#7e7eff",
"Noir": "#2f1f49",
"Nu": "#c9df40",
"NumPy": "#9C8AF9",
"Nunjucks": "#3d8137",
@@ -347,6 +370,8 @@
"OASv3-json": "#85ea2d",
"OASv3-yaml": "#85ea2d",
"OCaml": "#ef7a08",
"OMNeT++ MSG": "#a0e0a0",
"OMNeT++ NED": "#08607c",
"ObjectScript": "#424893",
"Objective-C": "#438eff",
"Objective-C++": "#6866fb",
@@ -363,6 +388,7 @@
"OpenSCAD": "#e5cd45",
"Option List": "#476732",
"Org": "#77aa99",
"OverpassQL": "#cce2aa",
"Oxygene": "#cdd0e3",
"Oz": "#fab738",
"P4": "#7055b5",
@@ -384,6 +410,7 @@
"PigLatin": "#fcd7de",
"Pike": "#005390",
"Pip Requirements": "#FFD343",
"Pkl": "#6b9543",
"PlantUML": "#fbbd16",
"PogoScript": "#d80074",
"Polar": "#ae81ff",
@@ -411,12 +438,14 @@
"QML": "#44a51c",
"Qt Script": "#00b841",
"Quake": "#882233",
"QuickBASIC": "#008080",
"R": "#198CE7",
"RAML": "#77d9fb",
"RBS": "#701516",
"RDoc": "#701516",
"REXX": "#d90e09",
"RMarkdown": "#198ce7",
"RON": "#a62c00",
"RPGLE": "#2BDE21",
"RUNOFF": "#665a4e",
"Racket": "#3c5caa",
@@ -436,6 +465,7 @@
"Riot": "#A71E49",
"RobotFramework": "#00c0b5",
"Roc": "#7c38f5",
"Rocq Prover": "#d0b68c",
"Roff": "#ecdebe",
"Roff Manpage": "#ecdebe",
"Rouge": "#cc0088",
@@ -451,6 +481,7 @@
"SRecode Template": "#348a34",
"STL": "#373b5e",
"SVG": "#ff9900",
"Sail": "#259dd5",
"SaltStack": "#646464",
"Sass": "#a53b70",
"Scala": "#c22d40",
@@ -465,6 +496,7 @@
"Shen": "#120F14",
"Simple File Verification": "#C9BFED",
"Singularity": "#64E6AD",
"Slang": "#1fbec9",
"Slash": "#007eff",
"Slice": "#003fa2",
"Slim": "#2b2b2b",
@@ -486,6 +518,7 @@
"SubRip Text": "#9e0101",
"SugarSS": "#2fcc9f",
"SuperCollider": "#46390b",
"Survex data": "#ffcc99",
"Svelte": "#ff3e00",
"Sway": "#00F58C",
"Sweave": "#198ce7",
@@ -499,6 +532,7 @@
"TSV": "#237346",
"TSX": "#3178c6",
"TXL": "#0178b8",
"Tact": "#48b5ff",
"Talon": "#333333",
"Tcl": "#e4cc98",
"TeX": "#3D6117",
@@ -509,9 +543,11 @@
"Textile": "#ffe7ac",
"Thrift": "#D12127",
"Toit": "#c2c9fb",
"Tree-sitter Query": "#8ea64c",
"Turing": "#cf142b",
"Twig": "#c1d026",
"TypeScript": "#3178c6",
"TypeSpec": "#4A3665",
"Typst": "#239dad",
"Unified Parallel C": "#4e3617",
"Unity3D Asset": "#222c37",
@@ -553,6 +589,7 @@
"XML Property List": "#0060ac",
"XQuery": "#5232e7",
"XSLT": "#EB8CEB",
"Xmake": "#22a079",
"Xojo": "#81bd41",
"Xonsh": "#285EEF",
"Xtend": "#24255d",
@@ -567,13 +604,16 @@
"Zephir": "#118f9e",
"Zig": "#ec915c",
"Zimpl": "#d67711",
"crontab": "#ead7ac",
"eC": "#913960",
"fish": "#4aae47",
"hoon": "#00b171",
"iCalendar": "#ec564c",
"jq": "#c7254e",
"kvlang": "#1da6e0",
"mIRC Script": "#3d57c3",
"mcfunction": "#E22837",
"mdsvex": "#5f9ea0",
"mupad": "#244963",
"nanorc": "#2d004d",
"nesC": "#94B0C7",
@@ -581,6 +621,8 @@
"q": "#0040cd",
"reStructuredText": "#141414",
"sed": "#64b970",
"templ": "#66D0DD",
"vCard": "#ee2647",
"wisp": "#7582D1",
"xBase": "#403a40"
}
+11 -1
View File
@@ -449,7 +449,11 @@ const TWO_HOURS = 7200;
const FOUR_HOURS = 14400;
const SIX_HOURS = 21600;
const EIGHT_HOURS = 28800;
const TWELVE_HOURS = 43200;
const ONE_DAY = 86400;
const TWO_DAY = ONE_DAY * 2;
const SIX_DAY = ONE_DAY * 6;
const TEN_DAY = ONE_DAY * 10;
const CONSTANTS = {
ONE_MINUTE,
@@ -461,8 +465,14 @@ const CONSTANTS = {
FOUR_HOURS,
SIX_HOURS,
EIGHT_HOURS,
TWELVE_HOURS,
ONE_DAY,
CARD_CACHE_SECONDS: SIX_HOURS,
TWO_DAY,
SIX_DAY,
TEN_DAY,
CARD_CACHE_SECONDS: ONE_DAY,
TOP_LANGS_CACHE_SECONDS: SIX_DAY,
PIN_CARD_CACHE_SECONDS: TEN_DAY,
ERROR_CACHE_SECONDS: TEN_MINUTES,
};
-82
View File
@@ -168,40 +168,6 @@ describe("Test /api/", () => {
);
});
it("should have proper cache", async () => {
const { req, res } = faker({}, data_stats);
await api(req, res);
expect(res.setHeader.mock.calls).toEqual([
["Content-Type", "image/svg+xml"],
[
"Cache-Control",
`max-age=${CONSTANTS.SIX_HOURS / 2}, s-maxage=${
CONSTANTS.SIX_HOURS
}, stale-while-revalidate=${CONSTANTS.ONE_DAY}`,
],
]);
});
it("should set proper cache", async () => {
const cache_seconds = 35000;
const { req, res } = faker({ cache_seconds }, data_stats);
await api(req, res);
expect(res.setHeader.mock.calls).toEqual([
["Content-Type", "image/svg+xml"],
[
"Cache-Control",
`max-age=${
cache_seconds / 2
}, s-maxage=${cache_seconds}, stale-while-revalidate=${
CONSTANTS.ONE_DAY
}`,
],
]);
});
it("should set shorter cache when error", async () => {
const { req, res } = faker({}, error);
await api(req, res);
@@ -217,54 +183,6 @@ describe("Test /api/", () => {
]);
});
it("should set proper cache with clamped values", async () => {
{
let { req, res } = faker({ cache_seconds: 200000 }, data_stats);
await api(req, res);
expect(res.setHeader.mock.calls).toEqual([
["Content-Type", "image/svg+xml"],
[
"Cache-Control",
`max-age=${CONSTANTS.ONE_DAY / 2}, s-maxage=${
CONSTANTS.ONE_DAY
}, stale-while-revalidate=${CONSTANTS.ONE_DAY}`,
],
]);
}
// note i'm using block scoped vars
{
let { req, res } = faker({ cache_seconds: 0 }, data_stats);
await api(req, res);
expect(res.setHeader.mock.calls).toEqual([
["Content-Type", "image/svg+xml"],
[
"Cache-Control",
`max-age=${CONSTANTS.SIX_HOURS / 2}, s-maxage=${
CONSTANTS.SIX_HOURS
}, stale-while-revalidate=${CONSTANTS.ONE_DAY}`,
],
]);
}
{
let { req, res } = faker({ cache_seconds: -10000 }, data_stats);
await api(req, res);
expect(res.setHeader.mock.calls).toEqual([
["Content-Type", "image/svg+xml"],
[
"Cache-Control",
`max-age=${CONSTANTS.SIX_HOURS / 2}, s-maxage=${
CONSTANTS.SIX_HOURS
}, stale-while-revalidate=${CONSTANTS.ONE_DAY}`,
],
]);
}
});
it("should allow changing ring_color", async () => {
const { req, res } = faker(
{
+1 -1
View File
@@ -18,7 +18,7 @@ const STATS_CARD_USER = "e2eninja";
const GIST_ID = "372cef55fd897b31909fdeb3a7262758";
const STATS_DATA = {
name: "E2ENinja",
name: "CodeNinja",
totalPRs: 1,
totalReviews: 0,
totalCommits: 3,
+1 -24
View File
@@ -4,7 +4,7 @@ import axios from "axios";
import MockAdapter from "axios-mock-adapter";
import { expect, it, describe, afterEach } from "@jest/globals";
import { renderGistCard } from "../src/cards/gist-card.js";
import { renderError, CONSTANTS } from "../src/common/utils.js";
import { renderError } from "../src/common/utils.js";
import gist from "../api/gist.js";
const gist_data = {
@@ -170,27 +170,4 @@ describe("Test /api/gist", () => {
renderError("Something went wrong", "Language not found"),
);
});
it("should have proper cache", async () => {
const req = {
query: {
id: "bbfce31e0217a3689c8d961a356cb10d",
},
};
const res = {
setHeader: jest.fn(),
send: jest.fn(),
};
mock.onPost("https://api.github.com/graphql").reply(200, gist_data);
await gist(req, res);
expect(res.setHeader).toBeCalledWith("Content-Type", "image/svg+xml");
expect(res.setHeader).toBeCalledWith(
"Cache-Control",
`max-age=${CONSTANTS.SIX_HOURS / 2}, s-maxage=${
CONSTANTS.SIX_HOURS
}, stale-while-revalidate=${CONSTANTS.ONE_DAY}`,
);
});
});
+1 -25
View File
@@ -4,7 +4,7 @@ import axios from "axios";
import MockAdapter from "axios-mock-adapter";
import pin from "../api/pin.js";
import { renderRepoCard } from "../src/cards/repo-card.js";
import { renderError, CONSTANTS } from "../src/common/utils.js";
import { renderError } from "../src/common/utils.js";
import { expect, it, describe, afterEach } from "@jest/globals";
const data_repo = {
@@ -201,28 +201,4 @@ describe("Test /api/pin", () => {
),
);
});
it("should have proper cache", async () => {
const req = {
query: {
username: "anuraghazra",
repo: "convoychat",
},
};
const res = {
setHeader: jest.fn(),
send: jest.fn(),
};
mock.onPost("https://api.github.com/graphql").reply(200, data_user);
await pin(req, res);
expect(res.setHeader).toBeCalledWith("Content-Type", "image/svg+xml");
expect(res.setHeader).toBeCalledWith(
"Cache-Control",
`max-age=${CONSTANTS.SIX_HOURS / 2}, s-maxage=${
CONSTANTS.SIX_HOURS
}, stale-while-revalidate=${CONSTANTS.ONE_DAY}`,
);
});
});
+1 -24
View File
@@ -4,7 +4,7 @@ import axios from "axios";
import MockAdapter from "axios-mock-adapter";
import topLangs from "../api/top-langs.js";
import { renderTopLanguages } from "../src/cards/top-languages-card.js";
import { renderError, CONSTANTS } from "../src/common/utils.js";
import { renderError } from "../src/common/utils.js";
import { expect, it, describe, afterEach } from "@jest/globals";
const data_langs = {
@@ -208,27 +208,4 @@ describe("Test /api/top-langs", () => {
renderError("Something went wrong", "Locale not found"),
);
});
it("should have proper cache", async () => {
const req = {
query: {
username: "anuraghazra",
},
};
const res = {
setHeader: jest.fn(),
send: jest.fn(),
};
mock.onPost("https://api.github.com/graphql").reply(200, data_langs);
await topLangs(req, res);
expect(res.setHeader).toBeCalledWith("Content-Type", "image/svg+xml");
expect(res.setHeader).toBeCalledWith(
"Cache-Control",
`max-age=${CONSTANTS.SIX_HOURS / 2}, s-maxage=${
CONSTANTS.SIX_HOURS
}, stale-while-revalidate=${CONSTANTS.ONE_DAY}`,
);
});
});
+1 -1
View File
@@ -11,4 +11,4 @@
"destination": "https://github.com/anuraghazra/github-readme-stats"
}
]
}
}