don't use protobuffers for dictionary loading on server
This commit is contained in:
parent
cd166ab47a
commit
62ba67d677
|
@ -4,8 +4,6 @@ import { CronJob } from "cron";
|
||||||
const collectionName = "ps-dictionary";
|
const collectionName = "ps-dictionary";
|
||||||
const allWordsCollectionName = "all-words";
|
const allWordsCollectionName = "all-words";
|
||||||
import {
|
import {
|
||||||
readDictionary,
|
|
||||||
readDictionaryInfo,
|
|
||||||
Types as T,
|
Types as T,
|
||||||
typePredicates as tp,
|
typePredicates as tp,
|
||||||
entryOfFull,
|
entryOfFull,
|
||||||
|
@ -27,9 +25,8 @@ const updateJob = new CronJob("* * * * *", updateDictionary, null, false);
|
||||||
let version: number = 0;
|
let version: number = 0;
|
||||||
|
|
||||||
async function fetchDictionary(): Promise<T.Dictionary> {
|
async function fetchDictionary(): Promise<T.Dictionary> {
|
||||||
const res = await fetch(process.env.LINGDOCS_DICTIONARY_URL || "");
|
const res = await fetch(process.env.LINGDOCS_DICTIONARY_URL + ".json" || "");
|
||||||
const buffer = await res.arrayBuffer();
|
return await res.json();
|
||||||
return readDictionary(buffer as Uint8Array);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async function fetchAllWords(): Promise<T.AllWordsWithInflections> {
|
async function fetchAllWords(): Promise<T.AllWordsWithInflections> {
|
||||||
|
@ -42,9 +39,10 @@ async function fetchAllWords(): Promise<T.AllWordsWithInflections> {
|
||||||
}
|
}
|
||||||
|
|
||||||
async function fetchDictionaryInfo(): Promise<T.DictionaryInfo> {
|
async function fetchDictionaryInfo(): Promise<T.DictionaryInfo> {
|
||||||
const res = await fetch(process.env.LINGDOCS_DICTIONARY_URL + "-info" || "");
|
const res = await fetch(
|
||||||
const buffer = await res.arrayBuffer();
|
process.env.LINGDOCS_DICTIONARY_URL + "-info.json" || ""
|
||||||
return readDictionaryInfo(buffer as Uint8Array);
|
);
|
||||||
|
return await res.json();
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function updateDictionary(): Promise<"no update" | "updated"> {
|
export async function updateDictionary(): Promise<"no update" | "updated"> {
|
||||||
|
|
Loading…
Reference in New Issue