Skip to content

Open-source and local-first Slack and Notion alternative that puts you in control of your data

679 B
Raw Blame
import { QueryError, QueryErrorCode } from '@colanode/client/queries';
import { AppService } from '@colanode/client/services/app-service';
import { WorkspaceService } from '@colanode/client/services/workspaces/workspace-service';

export abstract class WorkspaceQueryHandlerBase {
  protected readonly app: AppService;

  constructor(app: AppService) {
    this.app = app;
  }

  protected getWorkspace(userId: string): WorkspaceService {
    const workspace = this.app.getWorkspace(userId);
    if (!workspace) {
      throw new QueryError(
        QueryErrorCode.WorkspaceNotFound,
        'Workspace not found or has been deleted.'
      );
    }

    return workspace;
  }
}