From 9eba5d3e5da90987bb38ee33b505e0c26ea310d9 Mon Sep 17 00:00:00 2001 From: lonkaars Date: Thu, 29 Apr 2021 19:01:09 +0200 Subject: more endpoints --- .gitignore | 1 + index.ts | 10 +++++++++- makefile | 6 +++--- 3 files changed, 13 insertions(+), 4 deletions(-) diff --git a/.gitignore b/.gitignore index c5505f4..d1316d8 100644 --- a/.gitignore +++ b/.gitignore @@ -41,3 +41,4 @@ jspm_packages **/*.js downloads.html +out/ diff --git a/index.ts b/index.ts index 44c7b66..17aa551 100644 --- a/index.ts +++ b/index.ts @@ -1,5 +1,9 @@ import puppeteer from 'puppeteer'; import cheerio from 'cheerio'; +import { writeFile } from 'fs'; +import { promisify } from 'util'; + +var writeFileAsync = promisify(writeFile); import * as types from './types'; @@ -53,6 +57,10 @@ downloads.each(async (i, el) => { latestPre = version; } + for(var mcVersion in minecraftVersions) { + await writeFileAsync("./out/" + mcVersion, JSON.stringify(minecraftVersions[mcVersion])); + } + var response: types.APIResponse = { lastUpdate: Date.now(), all: versions, @@ -61,7 +69,7 @@ downloads.each(async (i, el) => { latestPre } - console.log(JSON.stringify(response)); + await writeFileAsync("./out/all", JSON.stringify(response)); process.exit(0); } }); diff --git a/makefile b/makefile index bfa68fb..ccfe6bd 100644 --- a/makefile +++ b/makefile @@ -1,4 +1,4 @@ -all: source +all: + mkdir out + node . -source: - node . > downloads.html -- cgit v1.2.3