Skip to content

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

Restructure some files in server

Hakan Shehu909afacf77d2
diff --git a/apps/server/src/controllers/client/accounts/account-sync.ts b/apps/server/src/api/client/controllers/accounts/account-sync.ts
similarity index 100%
rename from apps/server/src/controllers/client/accounts/account-sync.ts
rename to apps/server/src/api/client/controllers/accounts/account-sync.ts
diff --git a/apps/server/src/controllers/client/accounts/account-update.ts b/apps/server/src/api/client/controllers/accounts/account-update.ts
similarity index 100%
rename from apps/server/src/controllers/client/accounts/account-update.ts
rename to apps/server/src/api/client/controllers/accounts/account-update.ts
diff --git a/apps/server/src/controllers/client/accounts/email-login.ts b/apps/server/src/api/client/controllers/accounts/email-login.ts
similarity index 100%
rename from apps/server/src/controllers/client/accounts/email-login.ts
rename to apps/server/src/api/client/controllers/accounts/email-login.ts
diff --git a/apps/server/src/controllers/client/accounts/email-register.ts b/apps/server/src/api/client/controllers/accounts/email-register.ts
similarity index 100%
rename from apps/server/src/controllers/client/accounts/email-register.ts
rename to apps/server/src/api/client/controllers/accounts/email-register.ts
diff --git a/apps/server/src/controllers/client/accounts/email-verify.ts b/apps/server/src/api/client/controllers/accounts/email-verify.ts
similarity index 100%
rename from apps/server/src/controllers/client/accounts/email-verify.ts
rename to apps/server/src/api/client/controllers/accounts/email-verify.ts
diff --git a/apps/server/src/controllers/client/accounts/index.ts b/apps/server/src/api/client/controllers/accounts/index.ts
similarity index 100%
rename from apps/server/src/controllers/client/accounts/index.ts
rename to apps/server/src/api/client/controllers/accounts/index.ts
diff --git a/apps/server/src/controllers/client/accounts/login-google.ts b/apps/server/src/api/client/controllers/accounts/login-google.ts
similarity index 100%
rename from apps/server/src/controllers/client/accounts/login-google.ts
rename to apps/server/src/api/client/controllers/accounts/login-google.ts
diff --git a/apps/server/src/controllers/client/accounts/logout.ts b/apps/server/src/api/client/controllers/accounts/logout.ts
similarity index 97%
rename from apps/server/src/controllers/client/accounts/logout.ts
rename to apps/server/src/api/client/controllers/accounts/logout.ts
index 3ecbf225..58d9f574 100644
--- a/apps/server/src/controllers/client/accounts/logout.ts
+++ b/apps/server/src/api/client/controllers/accounts/logout.ts
@@ -5,7 +5,7 @@ import { eventBus } from '@/lib/event-bus';
import { ResponseBuilder } from '@/lib/response-builder';
export const logoutHandler = async (
- req: Request,
+ _: Request,
res: Response
): Promise<void> => {
const account = res.locals.account;
diff --git a/apps/server/src/controllers/client/avatars/avatar-download.ts b/apps/server/src/api/client/controllers/avatars/avatar-download.ts
similarity index 100%
rename from apps/server/src/controllers/client/avatars/avatar-download.ts
rename to apps/server/src/api/client/controllers/avatars/avatar-download.ts
diff --git a/apps/server/src/controllers/client/avatars/avatar-upload.ts b/apps/server/src/api/client/controllers/avatars/avatar-upload.ts
similarity index 100%
rename from apps/server/src/controllers/client/avatars/avatar-upload.ts
rename to apps/server/src/api/client/controllers/avatars/avatar-upload.ts
diff --git a/apps/server/src/controllers/client/avatars/index.ts b/apps/server/src/api/client/controllers/avatars/index.ts
similarity index 100%
rename from apps/server/src/controllers/client/avatars/index.ts
rename to apps/server/src/api/client/controllers/avatars/index.ts
diff --git a/apps/server/src/controllers/client/config/index.ts b/apps/server/src/api/client/controllers/config/index.ts
similarity index 100%
rename from apps/server/src/controllers/client/config/index.ts
rename to apps/server/src/api/client/controllers/config/index.ts
diff --git a/apps/server/src/controllers/client/index.ts b/apps/server/src/api/client/controllers/index.ts
similarity index 100%
rename from apps/server/src/controllers/client/index.ts
rename to apps/server/src/api/client/controllers/index.ts
diff --git a/apps/server/src/controllers/client/workspaces/files/file-download-get.ts b/apps/server/src/api/client/controllers/workspaces/files/file-download-get.ts
similarity index 100%
rename from apps/server/src/controllers/client/workspaces/files/file-download-get.ts
rename to apps/server/src/api/client/controllers/workspaces/files/file-download-get.ts
diff --git a/apps/server/src/controllers/client/workspaces/files/file-upload-complete.ts b/apps/server/src/api/client/controllers/workspaces/files/file-upload-complete.ts
similarity index 100%
rename from apps/server/src/controllers/client/workspaces/files/file-upload-complete.ts
rename to apps/server/src/api/client/controllers/workspaces/files/file-upload-complete.ts
diff --git a/apps/server/src/controllers/client/workspaces/files/file-upload-init.ts b/apps/server/src/api/client/controllers/workspaces/files/file-upload-init.ts
similarity index 100%
rename from apps/server/src/controllers/client/workspaces/files/file-upload-init.ts
rename to apps/server/src/api/client/controllers/workspaces/files/file-upload-init.ts
diff --git a/apps/server/src/controllers/client/workspaces/files/index.ts b/apps/server/src/api/client/controllers/workspaces/files/index.ts
similarity index 100%
rename from apps/server/src/controllers/client/workspaces/files/index.ts
rename to apps/server/src/api/client/controllers/workspaces/files/index.ts
diff --git a/apps/server/src/controllers/client/workspaces/index.ts b/apps/server/src/api/client/controllers/workspaces/index.ts
similarity index 100%
rename from apps/server/src/controllers/client/workspaces/index.ts
rename to apps/server/src/api/client/controllers/workspaces/index.ts
diff --git a/apps/server/src/controllers/client/workspaces/mutations/index.ts b/apps/server/src/api/client/controllers/workspaces/mutations/index.ts
similarity index 100%
rename from apps/server/src/controllers/client/workspaces/mutations/index.ts
rename to apps/server/src/api/client/controllers/workspaces/mutations/index.ts
diff --git a/apps/server/src/controllers/client/workspaces/mutations/mutations-sync.ts b/apps/server/src/api/client/controllers/workspaces/mutations/mutations-sync.ts
similarity index 100%
rename from apps/server/src/controllers/client/workspaces/mutations/mutations-sync.ts
rename to apps/server/src/api/client/controllers/workspaces/mutations/mutations-sync.ts
diff --git a/apps/server/src/controllers/client/workspaces/users/index.ts b/apps/server/src/api/client/controllers/workspaces/users/index.ts
similarity index 100%
rename from apps/server/src/controllers/client/workspaces/users/index.ts
rename to apps/server/src/api/client/controllers/workspaces/users/index.ts
diff --git a/apps/server/src/controllers/client/workspaces/users/user-create.ts b/apps/server/src/api/client/controllers/workspaces/users/user-create.ts
similarity index 100%
rename from apps/server/src/controllers/client/workspaces/users/user-create.ts
rename to apps/server/src/api/client/controllers/workspaces/users/user-create.ts
diff --git a/apps/server/src/controllers/client/workspaces/users/user-role-update.ts b/apps/server/src/api/client/controllers/workspaces/users/user-role-update.ts
similarity index 100%
rename from apps/server/src/controllers/client/workspaces/users/user-role-update.ts
rename to apps/server/src/api/client/controllers/workspaces/users/user-role-update.ts
diff --git a/apps/server/src/controllers/client/workspaces/workspace-create.ts b/apps/server/src/api/client/controllers/workspaces/workspace-create.ts
similarity index 100%
rename from apps/server/src/controllers/client/workspaces/workspace-create.ts
rename to apps/server/src/api/client/controllers/workspaces/workspace-create.ts
diff --git a/apps/server/src/controllers/client/workspaces/workspace-delete.ts b/apps/server/src/api/client/controllers/workspaces/workspace-delete.ts
similarity index 100%
rename from apps/server/src/controllers/client/workspaces/workspace-delete.ts
rename to apps/server/src/api/client/controllers/workspaces/workspace-delete.ts
diff --git a/apps/server/src/controllers/client/workspaces/workspace-get.ts b/apps/server/src/api/client/controllers/workspaces/workspace-get.ts
similarity index 100%
rename from apps/server/src/controllers/client/workspaces/workspace-get.ts
rename to apps/server/src/api/client/controllers/workspaces/workspace-get.ts
diff --git a/apps/server/src/controllers/client/workspaces/workspace-update.ts b/apps/server/src/api/client/controllers/workspaces/workspace-update.ts
similarity index 100%
rename from apps/server/src/controllers/client/workspaces/workspace-update.ts
rename to apps/server/src/api/client/controllers/workspaces/workspace-update.ts
diff --git a/apps/server/src/middlewares/auth.ts b/apps/server/src/api/client/middlewares/auth.ts
similarity index 100%
rename from apps/server/src/middlewares/auth.ts
rename to apps/server/src/api/client/middlewares/auth.ts
diff --git a/apps/server/src/middlewares/ip.ts b/apps/server/src/api/client/middlewares/ip.ts
similarity index 100%
rename from apps/server/src/middlewares/ip.ts
rename to apps/server/src/api/client/middlewares/ip.ts
diff --git a/apps/server/src/middlewares/workspace.ts b/apps/server/src/api/client/middlewares/workspace.ts
similarity index 100%
rename from apps/server/src/middlewares/workspace.ts
rename to apps/server/src/api/client/middlewares/workspace.ts
diff --git a/apps/server/src/routes/client.ts b/apps/server/src/api/client/routes.ts
similarity index 93%
rename from apps/server/src/routes/client.ts
rename to apps/server/src/api/client/routes.ts
index 038fbc53..bd5ff56c 100644
--- a/apps/server/src/routes/client.ts
+++ b/apps/server/src/api/client/routes.ts
@@ -21,9 +21,9 @@ import {
avatarUploadParameter,
mutationsSyncHandler,
emailVerifyHandler,
-} from '@/controllers/client';
-import { workspaceMiddleware } from '@/middlewares/workspace';
-import { authMiddleware } from '@/middlewares/auth';
+} from '@/api/client/controllers';
+import { workspaceMiddleware } from '@/api/client/middlewares/workspace';
+import { authMiddleware } from '@/api/client/middlewares/auth';
export const clientRouter = Router();
diff --git a/apps/server/src/api.ts b/apps/server/src/app.ts
similarity index 79%
rename from apps/server/src/api.ts
rename to apps/server/src/app.ts
index ff93ea7a..feb9fa70 100644
--- a/apps/server/src/api.ts
+++ b/apps/server/src/app.ts
@@ -4,13 +4,13 @@ import { createDebugger } from '@colanode/core';
import http from 'http';
-import { clientRouter } from '@/routes/client';
-import { ipMiddleware } from '@/middlewares/ip';
+import { clientRouter } from '@/api/client/routes';
+import { ipMiddleware } from '@/api/client/middlewares/ip';
import { socketService } from '@/services/socket-service';
-const debug = createDebugger('server:api');
+const debug = createDebugger('server:app');
-export const initApi = async () => {
+export const initApp = async () => {
const app = express();
const port = 3000;
diff --git a/apps/server/src/index.ts b/apps/server/src/index.ts
index 575badf0..b7b6c479 100644
--- a/apps/server/src/index.ts
+++ b/apps/server/src/index.ts
@@ -1,7 +1,7 @@
import dotenv from 'dotenv';
import { eventBus } from '@/lib/event-bus';
-import { initApi } from '@/api';
+import { initApp } from '@/app';
import { migrate } from '@/data/database';
import { initRedis } from '@/data/redis';
import { jobService } from '@/services/job-service';
@@ -12,7 +12,7 @@ dotenv.config();
const init = async () => {
await migrate();
await initRedis();
- await initApi();
+ await initApp();
jobService.initQueue();
await jobService.initWorker();
diff --git a/apps/server/src/lib/constants.ts b/apps/server/src/lib/constants.ts
deleted file mode 100644
index 3b23dff2..00000000
--- a/apps/server/src/lib/constants.ts
+++ /dev/null
@@ -1,26 +0,0 @@
-import { EntryRoles } from '@colanode/core';
-
-export const hasAdminAccess = (role: string): boolean => {
- return role === EntryRoles.Admin;
-};
-
-export const hasEditorAccess = (role: string): boolean => {
- return role === EntryRoles.Admin || role === EntryRoles.Editor;
-};
-
-export const hasCollaboratorAccess = (role: string): boolean => {
- return (
- role === EntryRoles.Admin ||
- role === EntryRoles.Editor ||
- role === EntryRoles.Collaborator
- );
-};
-
-export const hasViewerAccess = (role: string): boolean => {
- return (
- role === EntryRoles.Admin ||
- role === EntryRoles.Editor ||
- role === EntryRoles.Collaborator ||
- role === EntryRoles.Viewer
- );
-};