mirror of
https://github.com/colanode/colanode.git
synced 2025-12-16 11:47:47 +01:00
Restructure some files in server
This commit is contained in:
@@ -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;
|
||||
@@ -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();
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -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
|
||||
);
|
||||
};
|
||||
Reference in New Issue
Block a user