File tree Expand file tree Collapse file tree 2 files changed +7
-4
lines changed Expand file tree Collapse file tree 2 files changed +7
-4
lines changed Original file line number Diff line number Diff line change @@ -25,6 +25,7 @@ module.exports = async (req, res) => {
2525 custom_title,
2626 locale,
2727 layout,
28+ api_domain,
2829 } = req . query ;
2930
3031 res . setHeader ( "Content-Type" , "image/svg+xml" ) ;
@@ -34,7 +35,7 @@ module.exports = async (req, res) => {
3435 }
3536
3637 try {
37- const last7Days = await fetchLast7Days ( { username } ) ;
38+ const last7Days = await fetchLast7Days ( { username, api_domain } ) ;
3839
3940 let cacheSeconds = clampValue (
4041 parseInt ( cache_seconds || CONSTANTS . TWO_HOURS , 10 ) ,
Original file line number Diff line number Diff line change 11const axios = require ( "axios" ) ;
22
3- const fetchLast7Days = async ( { username } ) => {
3+ const fetchLast7Days = async ( { username, api_domain } ) => {
44 try {
55 const { data } = await axios . get (
6- `https://wakatime.com/api/v1/users/${ username } /stats/last_7_days?is_including_today=true` ,
6+ `https://${
7+ api_domain ? api_domain . replace ( / [ ^ a - z - .0 - 9 ] / gi, "" ) : "wakatime.com"
8+ } /api/v1/users/${ username } /stats/last_7_days?is_including_today=true`,
79 ) ;
810
911 return data . data ;
1012 } catch ( err ) {
11- if ( err . response . status === 404 ) {
13+ if ( err . response . status < 200 || err . response . status > 299 ) {
1214 throw new Error (
1315 "Wakatime user not found, make sure you have a wakatime profile" ,
1416 ) ;
You can’t perform that action at this time.
0 commit comments