🧱 JSON streaming WIP

This commit is contained in:
2021-12-19 15:06:03 -08:00
parent 269bdcb5ae
commit f3872f35b5

View File

@@ -2,7 +2,13 @@
import { Service, ServiceBroker, Context } from "moleculer"; import { Service, ServiceBroker, Context } from "moleculer";
import axios, { AxiosResponse } from "axios"; import axios, { AxiosResponse } from "axios";
import hyperquest from "hyperquest";
import JSONStream from "JSONStream";
import es from "event-stream";
import { matchScorer } from "../utils/searchmatchscorer.utils"; import { matchScorer } from "../utils/searchmatchscorer.utils";
const CV_BASE_URL = "https://comicvine.gamespot.com/api/"; const CV_BASE_URL = "https://comicvine.gamespot.com/api/";
console.log("KEYYYYYYYY", process.env.COMICVINE_API_KEY); console.log("KEYYYYYYYY", process.env.COMICVINE_API_KEY);
export default class ComicVineService extends Service { export default class ComicVineService extends Service {
@@ -65,7 +71,7 @@ export default class ComicVineService extends Service {
offset, offset,
resources, resources,
}, },
transformResponse: (r) => { transformResponse: r => {
const matches = JSON.parse(r); const matches = JSON.parse(r);
return matchScorer( return matchScorer(
matches.results, matches.results,