(ctx: Context)
| 89 | } |
| 90 | |
| 91 | async function handler(ctx: Context) { |
| 92 | const url = 'https://launchermeta.mojang.com/v1/products/java-runtime/2ec0cc96c44e5a76b9c8b7c39df7210883d12871/all.json'; |
| 93 | |
| 94 | const response: any = await got({ |
| 95 | method: 'get', |
| 96 | url, |
| 97 | responseType: 'json', |
| 98 | }); |
| 99 | |
| 100 | const data: any = response.data; |
| 101 | |
| 102 | const arch = ctx.req.param('arch') ?? 'all'; |
| 103 | const javaType = ctx.req.param('javaType') ?? 'all'; |
| 104 | |
| 105 | let items: DataItem[] = []; |
| 106 | |
| 107 | if (arch === 'all') { |
| 108 | for (const k in data) { |
| 109 | if (!Object.hasOwn(data, k)) { |
| 110 | continue; |
| 111 | } |
| 112 | items = [...items, ...generateArch(k, data[k], javaType)]; |
| 113 | } |
| 114 | } else { |
| 115 | items = [...items, ...generateArch(arch, data[arch], javaType)]; |
| 116 | } |
| 117 | |
| 118 | const title = 'Minecraft Java运行时'; |
| 119 | |
| 120 | return { |
| 121 | title, |
| 122 | link: 'https://www.minecraft.net/', |
| 123 | description: title, |
| 124 | item: items, |
| 125 | }; |
| 126 | } |
nothing calls this directly
no test coverage detected