1- import { defineEventHandler , setHeader , getQuery , createError } from "h3" ;
1+ import {
2+ defineEventHandler ,
3+ setHeader ,
4+ getRouterParams ,
5+ createError ,
6+ getQuery ,
7+ } from "h3" ;
28
39const BASE_URL = "https://pkg.pr.new" ;
410
511export default defineEventHandler ( async ( event ) => {
12+ const params = getRouterParams ( event ) ;
13+ const owner = params . owner as string ;
14+ const repo = params . repo as string ;
15+
616 const query = getQuery ( event ) ;
7- const owner = query . owner as string ;
8- const repo = query . repo as string ;
917 const style = ( query . style as string ) || "flat" ;
10- const label = ( query . label as string ) || "pkg.pr.new" ;
1118 const color = ( query . color as string ) || "0ea5e9" ;
1219
1320 if ( ! owner || ! repo ) {
@@ -18,10 +25,10 @@ export default defineEventHandler(async (event) => {
1825 }
1926
2027 const logoBase64 = getPkgPrNewLogoBase64 ( ) ;
21- const shieldsUrl = `https://img.shields.io/static/v1?label=${ encodeURIComponent ( label ) } &message=${ encodeURIComponent ( repo ) } &color=${ color } &style=${ style } &logo=data:image/svg+xml;base64,${ logoBase64 } ` ;
28+ const shieldsUrl = `https://img.shields.io/static/v1?label=&message=${ encodeURIComponent ( repo ) } &color=${ color } &style=${ style } &logo=data:image/svg+xml;base64,${ logoBase64 } ` ;
2229
2330 setHeader ( event , "Content-Type" , "image/svg+xml" ) ;
24- setHeader ( event , "Cache-Control" , "public, max-age=86400" ) ;
31+ setHeader ( event , "Cache-Control" , "public, max-age=86400" ) ; // Cache for 24 hours
2532
2633 const response = await fetch ( shieldsUrl ) ;
2734 const svg = await response . text ( ) ;
0 commit comments