From 36b6f73264fae72ae76d0c603d715c0d634dc949 Mon Sep 17 00:00:00 2001 From: simon3000 Date: Tue, 10 Dec 2019 03:06:21 +0100 Subject: [PATCH] upgrade got --- api/latest.js | 4 ++-- api/shared.js | 2 +- api/update.js | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/api/latest.js b/api/latest.js index 4765cb6..240a81b 100644 --- a/api/latest.js +++ b/api/latest.js @@ -20,14 +20,14 @@ latest.get('/:name/:platform', async ctx => { const ymlFile = fileMap[platform] if (match && ymlFile) { const ymlUrl = await getLatestURL({ file: ymlFile, ...match }) - const { body: yml } = await got(ymlUrl) + const yml = await got(ymlUrl).text() const { files } = yaml.safeLoad(yml) const file = files .map(({ url }) => url) .find(url => ['exe', 'dmg', 'AppImage'].find(ext => url.endsWith(ext))) if (file) { const url = await getLatestURL({ file, ...match }) - ctx.body = got(url, { stream: true }) + ctx.body = got.stream(url) } } }) diff --git a/api/shared.js b/api/shared.js index 8ae8b6b..c5fe16e 100644 --- a/api/shared.js +++ b/api/shared.js @@ -1,7 +1,7 @@ const got = require('got') exports.getLatestURL = async ({ file, repo, owner = 'dd-center' }) => { - const { body: releases } = await got(`https://api.github.com/repos/${owner}/${repo}/releases`, { json: true }) + const releases = await got(`https://api.github.com/repos/${owner}/${repo}/releases`).json() const asset = releases .flatMap(({ assets }) => assets) .find(({ name }) => name === file) diff --git a/api/update.js b/api/update.js index 1d8cd3e..020732f 100644 --- a/api/update.js +++ b/api/update.js @@ -1,5 +1,5 @@ const Router = require('koa-router') -const got = require('got') +const { stream } = require('got') const { getLatestURL, relays } = require('./shared') @@ -13,7 +13,7 @@ update.get('/:name/:file', async ctx => { if (match) { const url = await getLatestURL({ file, ...match }) if (url) { - ctx.body = got(url, { stream: true }) + ctx.body = stream(url) } } })