(env: Env, ctx: ExecutionContext)
| 4 | |
| 5 | // This updates the main array of fonts dataset |
| 6 | const updateArrayMetadata = async (env: Env, ctx: ExecutionContext) => { |
| 7 | const data = await getMetadata(env, ctx); |
| 8 | |
| 9 | // v1 Response |
| 10 | const list: ArrayMetadata = []; |
| 11 | |
| 12 | for (const value of Object.values(data)) { |
| 13 | list.push({ |
| 14 | id: value.id, |
| 15 | family: value.family, |
| 16 | subsets: value.subsets, |
| 17 | weights: value.weights, |
| 18 | styles: value.styles, |
| 19 | defSubset: value.defSubset, |
| 20 | variable: value.variable, |
| 21 | lastModified: value.lastModified, |
| 22 | category: value.category, |
| 23 | license: value.license, |
| 24 | type: value.type, |
| 25 | }); |
| 26 | } |
| 27 | |
| 28 | // Store the list in KV |
| 29 | ctx.waitUntil( |
| 30 | env.METADATA.put(METADATA_KEYS.fonts_arr, JSON.stringify(list)), |
| 31 | ); |
| 32 | return list; |
| 33 | }; |
| 34 | |
| 35 | export { updateArrayMetadata }; |
no test coverage detected