fix(api): v2 data endpoint
This commit is contained in:
parent
81b50b1798
commit
5d45679da6
@ -8,7 +8,7 @@ export default (server: FastifyInstance, options: RouteShorthandOptions, done: (
|
|||||||
const commonWordsUrl = `${dataUrl}/common-words.json`;
|
const commonWordsUrl = `${dataUrl}/common-words.json`;
|
||||||
const fixesUrl = `${dataUrl}/fixes.txt`;
|
const fixesUrl = `${dataUrl}/fixes.txt`;
|
||||||
const skipsUrl = `${dataUrl}/skips.json`;
|
const skipsUrl = `${dataUrl}/skips.json`;
|
||||||
const tokensUrl = `${dataUrl}/tokens.txt`;
|
const tokensUrl = `${dataUrl}/tokens.json`;
|
||||||
|
|
||||||
const results = await Promise.all([
|
const results = await Promise.all([
|
||||||
fetch(commonWordsUrl),
|
fetch(commonWordsUrl),
|
||||||
@ -16,19 +16,22 @@ export default (server: FastifyInstance, options: RouteShorthandOptions, done: (
|
|||||||
fetch(skipsUrl),
|
fetch(skipsUrl),
|
||||||
fetch(tokensUrl),
|
fetch(tokensUrl),
|
||||||
]);
|
]);
|
||||||
|
const skips = await results[2].json();
|
||||||
|
const tokens = await results[3].json();
|
||||||
|
|
||||||
reply.send({
|
reply.send({
|
||||||
data: {
|
data: {
|
||||||
classes: (await results[3].json()).classes,
|
classes: tokens.classes,
|
||||||
commonWords: await results[0].json(),
|
commonWords: await results[0].json(),
|
||||||
elements: (await results[3].json()).selectors,
|
elements: tokens.selectors,
|
||||||
fixes: (await results[1].text()).split('\n').filter((x) => !!x),
|
fixes: (await results[1].text()).split('\n').filter((x) => !!x),
|
||||||
skips: (await results[2].json()).domains,
|
skips: skips.domains,
|
||||||
tags: (await results[2].json()).tags,
|
tags: skips.tags,
|
||||||
},
|
},
|
||||||
success: true,
|
success: true,
|
||||||
});
|
});
|
||||||
} catch {
|
} catch (e) {
|
||||||
|
console.error(e);
|
||||||
reply.send({ success: false });
|
reply.send({ success: false });
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
Loading…
Reference in New Issue
Block a user