Skip to content

Commit

Permalink
cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
majodev committed May 29, 2023
1 parent 1eaf40a commit 3f98740
Show file tree
Hide file tree
Showing 4 changed files with 1 addition and 66 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ Download a zipped archive with all `.eot`, `.woff`, `.woff2`, `.svg`, `.ttf` fil
* Project upgraded to be compatible with Node.js v18+.
* Automated prebuilt Docker images via [GitHub Actions](https://github.com/majodev/google-webfonts-helper/actions).
* `/server` was fully refactored/modernized (async/await) and now compiles with TypeScript.
* Switch to `node:18-alpine` for the final image (the musl linux memory allocator works better with this server).
* Switch to `node:18` for the final image.
* `/client` can still be considered very legacy Angular code.

> 2022:
Expand Down
18 changes: 0 additions & 18 deletions server/logic/fetchCSS.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,24 +35,6 @@ export async function fetchCSS(family: string, cssSubsetString: string, type: ke

return res.data;

// const res = await fetch(url, {
// headers: {
// accept: "text/css,*/*;q=0.1",
// "User-Agent": userAgent,
// },
// });

// if (res.status !== 200) {
// throw new Error(`${url} fetchCSS request failed. status code: ${res.status} ${res.statusText}`);
// }

// const contentType = res.headers.get("content-type");

// if (_.isNil(contentType) || _.isEmpty(contentType) || contentType.indexOf("css") === -1) {
// throw new Error(`${url} fetchCSS request failed. expected "css" to be in content-type header: ${contentType}`);
// }

// return res.text();
},
{ retries: RETRIES }
);
Expand Down
32 changes: 0 additions & 32 deletions server/logic/fetchFontSubsetArchive.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,17 +75,8 @@ export async function fetchFontSubsetArchive(
try {
await finished(archive.generateNodeStream({
compression: "DEFLATE",
// streamFiles: true,
}).pipe(target));

// await finished(pipeline(archive.generateNodeStream({
// compression: "DEFLATE",
// streamFiles: true,
// }), target, (err) => {
// if (err) {
// console.error("fetchFontSubsetArchive archive.generateNodeStream pipe failed file=${subsetFontArchive.zipPath}", err);
// }
// }));
console.info(`fetchFontSubsetArchive create archive done! file=${subsetFontArchive.zipPath}`);
} catch (e) {
console.error("fetchFontSubsetArchive archive.generateNodeStream pipe failed", e);
Expand Down Expand Up @@ -118,29 +109,6 @@ async function fetchFontSubsetArchiveStream(url: string): Promise<Readable> {

return res.data;

// const response = await fetch(url);
// const contentType = response.headers.get("content-type");

// if (response.status !== 200) {
// throw new Error(`${url} fetchFontSubsetArchiveStream request failed. status code: ${response.status} ${response.statusText}`);
// }

// if (_.isNil(contentType) || _.isEmpty(contentType) || contentType.indexOf(format) === -1) {
// throw new Error(
// `${url} fetchFontSubsetArchiveStream request failed. expected ${format} to be in content-type header: ${contentType}`
// );
// }

// if (_.isNil(response.body)) {
// throw new Error(`${url} fetchFontSubsetArchiveStream request failed. response.body is null`);
// }

// // // hold in mem while creating archive.
// // return response.arrayBuffer();

// // TODO typing mismatch ReadableStream<any> vs ReadableStream<Uint8Array>
// // eslint-disable-next-line @typescript-eslint/no-explicit-any
// return Readable.fromWeb(<any>response.body);
},
{ retries: RETRIES }
);
Expand Down
15 changes: 0 additions & 15 deletions server/logic/fetchGoogleFonts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,21 +64,6 @@ export async function fetchGoogleFonts(): Promise<IFontItem[]> {

return transform(res.data);

// const res = await fetch(`https://www.googleapis.com/webfonts/v1/webfonts?sort=popularity&key=${config.GOOGLE_FONTS_API_KEY}`, {
// headers: {
// accept: "application/json",
// },
// });

// if (res.status !== 200) {
// throw new Error(`fetchGoogleFonts request failed. status code: ${res.status} ${res.statusText}`);
// }

// const resData: IGoogleFontsRes = await res.json();

// // console.log(JSON.stringify(resData));

// return transform(resData);
},
{ retries: RETRIES }
);
Expand Down

0 comments on commit 3f98740

Please sign in to comment.