initial public commit
This commit is contained in:
23
dist-node/loadAndParseTwtxt.js
Normal file
23
dist-node/loadAndParseTwtxt.js
Normal file
@@ -0,0 +1,23 @@
|
||||
import dayjs from "dayjs";
|
||||
import parseTwtxt from "./parseTwtxt.js";
|
||||
async function loadAndParseTwtxtFile(url = "") {
|
||||
if (!url) throw new Error("URL is required");
|
||||
try {
|
||||
const response = await fetch(url);
|
||||
const twtxtFile = await response.text();
|
||||
const lastModified = dayjs(
|
||||
response.headers.get("Last-Modified")
|
||||
).toISOString();
|
||||
return {
|
||||
...parseTwtxt(twtxtFile),
|
||||
lastModified
|
||||
};
|
||||
} catch (err) {
|
||||
console.error(err);
|
||||
throw err;
|
||||
}
|
||||
}
|
||||
export {
|
||||
loadAndParseTwtxtFile as default
|
||||
};
|
||||
//# sourceMappingURL=loadAndParseTwtxt.js.map
|
||||
Reference in New Issue
Block a user