mirror of
https://github.com/System-End/github-readme-stats.git
synced 2026-04-20 00:35:23 +00:00
* 🚀 Prettier config * 🚀 hide_border for Repo Card * fix: wrong total commits (#490) * chore: run prettier on all files * chore: lol lets add the trailing commas Co-authored-by: Anurag Hazra <hazru.anurag@gmail.com>
59 lines
1.3 KiB
JavaScript
59 lines
1.3 KiB
JavaScript
require("dotenv").config();
|
|
const {
|
|
renderError,
|
|
parseBoolean,
|
|
clampValue,
|
|
CONSTANTS,
|
|
} = require("../src/common/utils");
|
|
const { fetchLast7Days } = require("../src/fetchers/wakatime-fetcher");
|
|
const wakatimeCard = require("../src/cards/wakatime-card");
|
|
|
|
module.exports = async (req, res) => {
|
|
const {
|
|
username,
|
|
title_color,
|
|
icon_color,
|
|
hide_border,
|
|
line_height,
|
|
text_color,
|
|
bg_color,
|
|
theme,
|
|
cache_seconds,
|
|
hide_title,
|
|
hide_progress,
|
|
} = req.query;
|
|
|
|
res.setHeader("Content-Type", "image/svg+xml");
|
|
|
|
try {
|
|
const last7Days = await fetchLast7Days({ username });
|
|
|
|
let cacheSeconds = clampValue(
|
|
parseInt(cache_seconds || CONSTANTS.TWO_HOURS, 10),
|
|
CONSTANTS.TWO_HOURS,
|
|
CONSTANTS.ONE_DAY,
|
|
);
|
|
|
|
if (!cache_seconds) {
|
|
cacheSeconds = CONSTANTS.FOUR_HOURS;
|
|
}
|
|
|
|
res.setHeader("Cache-Control", `public, max-age=${cacheSeconds}`);
|
|
|
|
return res.send(
|
|
wakatimeCard(last7Days, {
|
|
hide_title: parseBoolean(hide_title),
|
|
hide_border: parseBoolean(hide_border),
|
|
line_height,
|
|
title_color,
|
|
icon_color,
|
|
text_color,
|
|
bg_color,
|
|
theme,
|
|
hide_progress,
|
|
}),
|
|
);
|
|
} catch (err) {
|
|
return res.send(renderError(err.message, err.secondaryMessage));
|
|
}
|
|
};
|