forked from anuraghazra/github-readme-stats
-
Notifications
You must be signed in to change notification settings - Fork 0
/
pin.js
36 lines (31 loc) · 741 Bytes
/
pin.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
require("dotenv").config();
const { renderError } = require("../src/utils");
const fetchRepo = require("../src/fetchRepo");
const renderRepoCard = require("../src/renderRepoCard");
module.exports = async (req, res) => {
const {
username,
repo,
title_color,
icon_color,
text_color,
bg_color,
} = req.query;
let repoData;
res.setHeader("Cache-Control", "public, max-age=1800");
res.setHeader("Content-Type", "image/svg+xml");
try {
repoData = await fetchRepo(username, repo);
} catch (err) {
console.log(err);
return res.send(renderError(err.message));
}
res.send(
renderRepoCard(repoData, {
title_color,
icon_color,
text_color,
bg_color,
})
);
};