New constants/config merge system

This commit is contained in:
Cadence Fish
2020-01-28 16:14:21 +13:00
parent fb6081a719
commit cf8fd6b86b
8 changed files with 43 additions and 9 deletions

View File

@@ -4,9 +4,9 @@ const {extractSharedData} = require("./utils/body")
const {TtlCache, RequestCache} = require("./cache")
require("./testimports")(constants, request, extractSharedData, RequestCache)
const requestCache = new RequestCache(constants.resource_cache_time)
const requestCache = new RequestCache(constants.caching.resource_cache_time)
/** @type {import("./cache").TtlCache<import("./structures/TimelineEntry")>} */
const timelineEntryCache = new TtlCache(constants.resource_cache_time)
const timelineEntryCache = new TtlCache(constants.caching.resource_cache_time)
function fetchUser(username) {
return requestCache.getOrFetch("user/"+username, () => {
@@ -39,6 +39,7 @@ function fetchTimelinePage(userID, after) {
}))
return requestCache.getOrFetchPromise("page/"+after, () => {
return request(`https://www.instagram.com/graphql/query/?${p.toString()}`).then(res => res.json()).then(root => {
if (!root.data) console.error("missing data:", root) //todo: please make this better.
/** @type {import("./types").PagedEdges<import("./types").TimelineEntryN2>} */
const timeline = root.data.user.edge_owner_to_timeline_media
return timeline