Files
notesnook/apps/web/src/common/db.js

46 lines
1.3 KiB
JavaScript
Raw Normal View History

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;
async function initializeDatabase() {
const { default: Database } = await import("notes-core/api");
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",
// });
// } else {
// 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-04-06 11:55:23 +05:00
await db.init();
return db;
2021-02-17 01:24:20 +05:00
}
export { db, initializeDatabase };