|
|
@@ -8,6 +8,7 @@ import { env } from '$env/dynamic/private';
|
|
|
|
|
|
import { Auth } from './auth';
|
|
|
import { Catalog } from './catalog';
|
|
|
+import { Gateway } from './gateway';
|
|
|
import { Resources } from './resources';
|
|
|
import { WorkspaceManager } from './workspace';
|
|
|
|
|
|
@@ -20,6 +21,7 @@ class Server {
|
|
|
#auth: Auth | undefined;
|
|
|
#catalog!: Catalog;
|
|
|
#resources!: Resources;
|
|
|
+ #gateway!: Gateway;
|
|
|
|
|
|
async init(): Promise<void> {
|
|
|
if (this.#initialized) return;
|
|
|
@@ -29,6 +31,7 @@ class Server {
|
|
|
await Promise.all([this.#createWorkspaceManager(), this.#createAuth()]);
|
|
|
const workspaces = this.#ws.list();
|
|
|
await Promise.all([this.#createCatalog(workspaces), this.#createResources(workspaces)]);
|
|
|
+ await Promise.all([this.#createGateway()]);
|
|
|
|
|
|
log.info('Server ready');
|
|
|
}
|
|
|
@@ -67,6 +70,14 @@ class Server {
|
|
|
this.#resources = resources;
|
|
|
}
|
|
|
|
|
|
+ async #createGateway(): Promise<void> {
|
|
|
+ const gateway = new Gateway({
|
|
|
+ endpoint: env.GATEWAY_ENDPOINT || 'http://localhost',
|
|
|
+ apiKey: env.GATEWAY_KEY,
|
|
|
+ });
|
|
|
+ this.#gateway = gateway;
|
|
|
+ }
|
|
|
+
|
|
|
get ws(): WorkspaceManager {
|
|
|
return this.#ws;
|
|
|
}
|
|
|
@@ -83,6 +94,10 @@ class Server {
|
|
|
return this.#resources;
|
|
|
}
|
|
|
|
|
|
+ get gateway(): Gateway {
|
|
|
+ return this.#gateway;
|
|
|
+ }
|
|
|
+
|
|
|
async #saveFile(fileName: string, file: File): Promise<string> {
|
|
|
await fs.mkdir(path.dirname(fileName), { recursive: true });
|
|
|
let usedFileName = fileName;
|