Skip to content

Commit

Permalink
Added yaml JSON-Schema support (#364)
Browse files Browse the repository at this point in the history
  • Loading branch information
Abrifq authored Oct 23, 2023
1 parent 23b0afc commit 0d1e6fa
Show file tree
Hide file tree
Showing 6 changed files with 471 additions and 4 deletions.
3 changes: 2 additions & 1 deletion src/cache.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import got from "got";
import logger from "./logger.js";
import { readSchemaFromFileContents } from "./io.js";

class Cache {
constructor(flatCache, ttl) {
Expand Down Expand Up @@ -60,7 +61,7 @@ class Cache {
try {
logger.debug(`Cache miss: calling ${url}`);
const resp = await got(url);
const parsedBody = JSON.parse(resp.body);
const parsedBody = readSchemaFromFileContents(url, resp.body);
if (this.ttl > 0) {
this.cache.setKey(url, { timestamp: Date.now(), body: parsedBody });
this.cache.save(true);
Expand Down
Loading

0 comments on commit 0d1e6fa

Please sign in to comment.