Skip to content

Commit

Permalink
Add fallback.xlsx
Browse files Browse the repository at this point in the history
  • Loading branch information
gmanriqueUy committed Dec 6, 2023
1 parent 7c13d26 commit e613a26
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 1 deletion.
1 change: 1 addition & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ COPY --from=build /myapp/node_modules/.prisma /myapp/node_modules/.prisma

COPY --from=build /myapp/build /myapp/build
COPY --from=build /myapp/scripts/build /myapp/scripts/build
COPY --from=build /myapp/scripts/seed/fallback.xlsx /myapp/scripts/build/seed/fallback.xlsx
COPY --from=build /myapp/public /myapp/public
COPY --from=build /myapp/package.json /myapp/package.json
COPY --from=build /myapp/start.sh /myapp/start.sh
Expand Down
10 changes: 9 additions & 1 deletion scripts/seed/downloadFile.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,16 @@
import { fetch } from "@remix-run/node";
import { readFile } from "fs/promises";

const URL =
"https://www5.ine.gub.uy/documents/Estad%C3%ADsticasecon%C3%B3micas/SERIES%20Y%20OTROS/Cotizaci%C3%B3n%20de%20monedas/Cotizaci%C3%B3n%20monedas.xlsx";

export async function downloadFile() {
return (await fetch(URL)).arrayBuffer();
const response = await fetch(URL);

if (response.status === 200) {
return response.arrayBuffer();
}

console.log("File download failed. Reading fallback.xlsx");
return await readFile(__dirname + "/fallback.xlsx");
}
Binary file added scripts/seed/fallback.xlsx
Binary file not shown.

0 comments on commit e613a26

Please sign in to comment.