2021-10-26 09:36:42 +05:00
|
|
|
import { EventSourcePolyfill as EventSource } from "event-source-polyfill";
|
|
|
|
|
//const EventSource = NativeEventSource || EventSourcePolyfill;
|
|
|
|
|
// OR: may also need to set as global property
|
|
|
|
|
//global.EventSource = NativeEventSource || EventSourcePolyfill;
|
|
|
|
|
|
2021-09-23 15:18:11 +05:00
|
|
|
global.HTMLParser = new DOMParser().parseFromString(
|
|
|
|
|
"<body></body>",
|
|
|
|
|
"text/html"
|
|
|
|
|
);
|
2021-02-17 01:24:20 +05:00
|
|
|
/**
|
|
|
|
|
* @type {import("notes-core/api").default}
|
|
|
|
|
*/
|
|
|
|
|
var db;
|
2021-08-04 23:27:16 +05:00
|
|
|
async function initializeDatabase() {
|
|
|
|
|
const { default: Database } = await import("notes-core/api");
|
2021-10-23 10:58:44 +05:00
|
|
|
const { default: Storage } = await import("../interfaces/storage");
|
|
|
|
|
const { default: FS } = await import("../interfaces/fs");
|
|
|
|
|
db = new Database(Storage, EventSource, FS);
|
|
|
|
|
|
|
|
|
|
// if (isTesting()) {
|
2022-03-23 19:45:04 +05:00
|
|
|
// db.host({
|
|
|
|
|
// API_HOST: "https://api.notesnook.com",
|
|
|
|
|
// AUTH_HOST: "https://auth.streetwriters.co",
|
|
|
|
|
// SSE_HOST: "https://events.streetwriters.co",
|
|
|
|
|
// });
|
2021-10-23 10:58:44 +05:00
|
|
|
// } else {
|
2021-10-26 09:36:42 +05:00
|
|
|
// db.host({
|
|
|
|
|
// API_HOST: "http://localhost:5264",
|
|
|
|
|
// AUTH_HOST: "http://localhost:8264",
|
|
|
|
|
// SSE_HOST: "http://localhost:7264",
|
|
|
|
|
// });
|
2022-03-23 19:45:04 +05:00
|
|
|
db.host({
|
|
|
|
|
API_HOST: "http://192.168.10.29:5264",
|
|
|
|
|
AUTH_HOST: "http://192.168.10.29:8264",
|
|
|
|
|
SSE_HOST: "http://192.168.10.29:7264",
|
|
|
|
|
ISSUES_HOST: "http://192.168.10.29:2624",
|
|
|
|
|
SUBSCRIPTIONS_HOST: "http://192.168.10.29:9264",
|
|
|
|
|
});
|
2021-10-23 10:58:44 +05:00
|
|
|
// }
|
2021-04-06 11:55:23 +05:00
|
|
|
|
2021-08-04 23:27:16 +05:00
|
|
|
await db.init();
|
|
|
|
|
return db;
|
2021-02-17 01:24:20 +05:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export { db, initializeDatabase };
|