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