Skip to content

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

Update to express v5

Hakan Shehuf71113dda7ec
diff --git a/apps/server/package.json b/apps/server/package.json
index 5db59b9b..7b8ab884 100644
--- a/apps/server/package.json
+++ b/apps/server/package.json
@@ -21,7 +21,7 @@
"devDependencies": {
"@types/bcrypt": "^5.0.2",
"@types/cors": "^2.8.17",
- "@types/express": "^4.17.21",
+ "@types/express": "^5.0.0",
"@types/multer": "^1.4.12",
"@types/node": "^22.10.1",
"@types/nodemailer": "^6.4.17",
@@ -41,7 +41,7 @@
"bullmq": "^5.30.1",
"cors": "^2.8.5",
"dotenv": "^16.4.5",
- "express": "^4.21.1",
+ "express": "^5.0.1",
"js-sha256": "^0.11.0",
"kafkajs": "^2.2.4",
"kysely": "^0.27.4",
diff --git a/apps/server/src/middlewares/auth.ts b/apps/server/src/middlewares/auth.ts
index 6a6087f2..ceca4395 100644
--- a/apps/server/src/middlewares/auth.ts
+++ b/apps/server/src/middlewares/auth.ts
@@ -1,33 +1,32 @@
+import { NextFunction, Request, Response, RequestHandler } from 'express';
+
import { verifyToken } from '@/lib/tokens';
-import {
- ApiError,
- ColanodeNextFunction,
- ColanodeRequest,
- ColanodeResponse,
-} from '@/types/api';
+import { ApiError } from '@/types/api';
-export const authMiddleware = async (
- req: ColanodeRequest,
- res: ColanodeResponse,
- next: ColanodeNextFunction
+export const authMiddleware: RequestHandler = async (
+ req: Request,
+ res: Response,
+ next: NextFunction
) => {
- const token = req.header('Authorization')?.split(' ')[1];
+ const token = req.headers.authorization?.split(' ')[1];
if (!token) {
- return res.status(401).json({
+ res.status(401).json({
code: ApiError.Unauthorized,
message: 'Access Denied: No Token Provided!',
});
+ return;
}
const result = await verifyToken(token);
if (!result.authenticated) {
- return res.status(400).json({
+ res.status(400).json({
code: ApiError.Unauthorized,
message: 'Invalid Token',
});
+ return;
}
- req.account = result.account;
+ res.locals.account = result.account;
next();
};
diff --git a/apps/server/src/routes/accounts.ts b/apps/server/src/routes/accounts.ts
index 583474a6..74f4eef6 100644
--- a/apps/server/src/routes/accounts.ts
+++ b/apps/server/src/routes/accounts.ts
@@ -24,7 +24,7 @@ import { generateToken } from '@/lib/tokens';
import { authMiddleware } from '@/middlewares/auth';
import { nodeService } from '@/services/node-service';
import { workspaceService } from '@/services/workspace-service';
-import { ApiError, ColanodeRequest, ColanodeResponse } from '@/types/api';
+import { ApiError } from '@/types/api';
const GoogleUserInfoUrl = 'https://www.googleapis.com/oauth2/v1/userinfo';
const SaltRounds = 10;
@@ -48,10 +48,11 @@ accountsRouter.post('/register/email', async (req: Request, res: Response) => {
let account: SelectAccount | null | undefined = null;
if (existingAccount) {
if (existingAccount.status !== AccountStatus.Pending) {
- return res.status(400).json({
+ res.status(400).json({
code: ApiError.EmailAlreadyExists,
message: 'Email already exists.',
});
+ return;
}
account = await database
@@ -81,14 +82,15 @@ accountsRouter.post('/register/email', async (req: Request, res: Response) => {
}
if (!account) {
- return res.status(500).json({
+ res.status(500).json({
code: ApiError.InternalServerError,
message: 'Failed to create account.',
});
+ return;
}
const output = await buildLoginOutput(account);
- return res.status(200).json(output);
+ res.status(200).json(output);
});
accountsRouter.post('/login/email', async (req: Request, res: Response) => {
@@ -102,24 +104,27 @@ accountsRouter.post('/login/email', async (req: Request, res: Response) => {
.executeTakeFirst();
if (!account) {
- return res.status(400).json({
+ res.status(400).json({
code: ApiError.EmailOrPasswordIncorrect,
message: 'Invalid credentials.',
});
+ return;
}
if (account.status === AccountStatus.Pending) {
- return res.status(400).json({
+ res.status(400).json({
code: ApiError.UserPendingActivation,
message: 'User is pending activation.',
});
+ return;
}
if (!account.password) {
- return res.status(400).json({
+ res.status(400).json({
code: ApiError.EmailOrPasswordIncorrect,
message: 'Invalid credentials.',
});
+ return;
}
const preHashedPassword = sha256(input.password);
@@ -129,14 +134,15 @@ accountsRouter.post('/login/email', async (req: Request, res: Response) => {
);
if (!passwordMatch) {
- return res.status(400).json({
+ res.status(400).json({
code: ApiError.EmailOrPasswordIncorrect,
message: 'Invalid credentials.',
});
+ return;
}
const output = await buildLoginOutput(account);
- return res.status(200).json(output);
+ res.status(200).json(output);
});
accountsRouter.post('/login/google', async (req: Request, res: Response) => {
@@ -145,19 +151,21 @@ accountsRouter.post('/login/google', async (req: Request, res: Response) => {
const userInfoResponse = await axios.get(url);
if (userInfoResponse.status !== 200) {
- return res.status(400).json({
+ res.status(400).json({
code: ApiError.GoogleAuthFailed,
message: 'Failed to authenticate with Google.',
});
+ return;
}
const googleUser: GoogleUserInfo = userInfoResponse.data;
if (!googleUser) {
- return res.status(400).json({
+ res.status(400).json({
code: ApiError.GoogleAuthFailed,
message: 'Failed to authenticate with Google.',
});
+ return;
}
const existingAccount = await database
@@ -184,7 +192,7 @@ accountsRouter.post('/login/google', async (req: Request, res: Response) => {
}
const output = await buildLoginOutput(existingAccount);
- return res.status(200).json(output);
+ res.status(200).json(output);
}
const newAccount = await database
@@ -201,78 +209,85 @@ accountsRouter.post('/login/google', async (req: Request, res: Response) => {
.executeTakeFirst();
if (!newAccount) {
- return res.status(500).json({
+ res.status(500).json({
code: ApiError.InternalServerError,
message: 'Failed to create account.',
});
+ return;
}
const output = await buildLoginOutput(newAccount);
- return res.status(200).json(output);
+ res.status(200).json(output);
});
accountsRouter.delete(
'/logout',
authMiddleware,
- async (req: ColanodeRequest, res: ColanodeResponse) => {
- if (!req.account) {
- return res.status(401).json({
+ async (req: Request, res: Response) => {
+ const account = res.locals.account;
+ if (!account) {
+ res.status(401).json({
code: ApiError.Unauthorized,
message: 'Unauthorized.',
});
+ return;
}
await database
.deleteFrom('devices')
- .where('id', '=', req.account.deviceId)
+ .where('id', '=', account.deviceId)
.execute();
- return res.status(200).end();
+ res.status(200).end();
}
);
accountsRouter.put(
'/:id',
authMiddleware,
- async (req: ColanodeRequest, res: ColanodeResponse) => {
+ async (req: Request, res: Response) => {
const id = req.params.id;
const input: AccountUpdateInput = req.body;
- if (!req.account) {
- return res.status(401).json({
+ if (!res.locals.account) {
+ res.status(401).json({
code: ApiError.Unauthorized,
message: 'Unauthorized.',
});
+ return;
}
- if (id !== req.account.id) {
- return res.status(400).json({
+ if (id !== res.locals.account.id) {
+ res.status(400).json({
code: ApiError.BadRequest,
message: 'Invalid account id.',
});
+ return;
}
const account = await database
.selectFrom('accounts')
- .where('id', '=', req.account.id)
+ .where('id', '=', res.locals.account.id)
.selectAll()
.executeTakeFirst();
if (!account) {
- return res.status(404).json({
+ res.status(404).json({
code: ApiError.ResourceNotFound,
message: 'Account not found.',
});
+ return;
}
const nameChanged = account.name !== input.name;
const avatarChanged = account.avatar !== input.avatar;
if (!nameChanged && !avatarChanged) {
- return res.status(400).json({
+ res.status(400).json({
code: ApiError.BadRequest,
message: 'Nothing to update.',
});
+ return;
}
await database
@@ -282,7 +297,7 @@ accountsRouter.put(
avatar: input.avatar,
updated_at: new Date(),
})
- .where('id', '=', req.account.id)
+ .where('id', '=', account.id)
.execute();
const users = await database
@@ -294,7 +309,7 @@ accountsRouter.put(
database
.selectFrom('workspace_users')
.select('id')
- .where('account_id', '=', req.account.id)
+ .where('account_id', '=', account.id)
)
.execute();
@@ -334,32 +349,34 @@ accountsRouter.put(
avatar: input.avatar,
};
- return res.status(200).json(output);
+ res.status(200).json(output);
}
);
accountsRouter.get(
'/sync',
authMiddleware,
- async (req: ColanodeRequest, res: ColanodeResponse) => {
- if (!req.account) {
- return res.status(401).json({
+ async (req: Request, res: Response) => {
+ if (!res.locals.account) {
+ res.status(401).json({
code: ApiError.Unauthorized,
message: 'Unauthorized.',
});
+ return;
}
const account = await database
.selectFrom('accounts')
- .where('id', '=', req.account.id)
+ .where('id', '=', res.locals.account.id)
.selectAll()
.executeTakeFirst();
if (!account) {
- return res.status(404).json({
+ res.status(404).json({
code: ApiError.ResourceNotFound,
message: 'Account not found.',
});
+ return;
}
const workspaceOutputs: WorkspaceOutput[] = [];
@@ -411,7 +428,7 @@ accountsRouter.get(
workspaces: workspaceOutputs,
};
- return res.status(200).json(output);
+ res.status(200).json(output);
}
);
diff --git a/apps/server/src/routes/avatars.ts b/apps/server/src/routes/avatars.ts
index fd2ef790..fbeef2c4 100644
--- a/apps/server/src/routes/avatars.ts
+++ b/apps/server/src/routes/avatars.ts
@@ -1,4 +1,4 @@
-import { GetObjectCommand,PutObjectCommand } from '@aws-sdk/client-s3';
+import { GetObjectCommand, PutObjectCommand } from '@aws-sdk/client-s3';
import { generateId, IdType } from '@colanode/core';
import { Router } from 'express';
import multer from 'multer';
@@ -33,7 +33,8 @@ const upload = multer({
avatarsRouter.post('/', upload.single('avatar'), async (req, res) => {
try {
if (!req.file) {
- return res.status(400).json({ error: 'No file uploaded' });
+ res.status(400).json({ error: 'No file uploaded' });
+ return;
}
// Resize image to a maximum of 500x500 pixels while keeping aspect ratio, and convert to JPEG using Sharp
@@ -55,10 +56,10 @@ avatarsRouter.post('/', upload.single('avatar'), async (req, res) => {
});
await avatarStorage.send(command);
- return res.json({ success: true, id: avatarId });
+ res.json({ success: true, id: avatarId });
} catch (error) {
console.error('Error uploading file:', error);
- return res.status(500).json({ error: 'Failed to upload avatar' });
+ res.status(500).json({ error: 'Failed to upload avatar' });
}
});
@@ -72,16 +73,17 @@ avatarsRouter.get('/:id', async (req, res) => {
const avatarResponse = await avatarStorage.send(command);
if (!avatarResponse.Body) {
- return res.status(404).json({ error: 'Avatar not found' });
+ res.status(404).json({ error: 'Avatar not found' });
+ return;
}
if (avatarResponse.Body instanceof Readable) {
avatarResponse.Body.pipe(res);
} else {
- return res.status(404).json({ error: 'Avatar not found' });
+ res.status(404).json({ error: 'Avatar not found' });
}
} catch (error) {
console.error('Error downloading avatar:', error);
- return res.status(500).json({ error: 'Failed to download avatar' });
+ res.status(500).json({ error: 'Failed to download avatar' });
}
});
diff --git a/apps/server/src/routes/files.ts b/apps/server/src/routes/files.ts
index d00901f6..c2f3b8ff 100644
--- a/apps/server/src/routes/files.ts
+++ b/apps/server/src/routes/files.ts
@@ -11,7 +11,7 @@ import {
extractFileType,
UploadMetadata,
} from '@colanode/core';
-import { Router } from 'express';
+import { Request, Response, Router } from 'express';
import { database } from '@/data/database';
import { redis } from '@/data/redis';
@@ -19,21 +19,22 @@ import { BUCKET_NAMES, filesStorage } from '@/data/storage';
import { hasCollaboratorAccess } from '@/lib/constants';
import { fetchNodeRole } from '@/lib/nodes';
import { nodeService } from '@/services/node-service';
-import { ApiError, ColanodeRequest, ColanodeResponse } from '@/types/api';
+import { ApiError } from '@/types/api';
export const filesRouter = Router();
filesRouter.get(
'/:workspaceId/:fileId',
- async (req: ColanodeRequest, res: ColanodeResponse) => {
+ async (req: Request, res: Response) => {
const workspaceId = req.params.workspaceId as string;
const fileId = req.params.fileId as string;
- if (!req.account) {
- return res.status(401).json({
+ if (!res.locals.account) {
+ res.status(401).json({
code: ApiError.Unauthorized,
message: 'Unauthorized.',
});
+ return;
}
const workspace = await database
@@ -43,32 +44,35 @@ filesRouter.get(
.executeTakeFirst();
if (!workspace) {
- return res.status(404).json({
+ res.status(404).json({
code: ApiError.ResourceNotFound,
message: 'Workspace not found.',
});
+ return;
}
const workspaceUser = await database
.selectFrom('workspace_users')
.selectAll()
.where('workspace_id', '=', workspace.id)
- .where('account_id', '=', req.account.id)
+ .where('account_id', '=', res.locals.account.id)
.executeTakeFirst();
if (!workspaceUser) {
- return res.status(403).json({
+ res.status(403).json({
code: ApiError.Forbidden,
message: 'Forbidden.',
});
+ return;
}
const role = await fetchNodeRole(fileId, workspaceUser.id);
if (role === null || !hasCollaboratorAccess(role)) {
- return res.status(403).json({
+ res.status(403).json({
code: ApiError.Forbidden,
message: 'Forbidden.',
});
+ return;
}
const node = await database
@@ -78,17 +82,19 @@ filesRouter.get(
.executeTakeFirst();
if (!node) {
- return res.status(404).json({
+ res.status(404).json({
code: ApiError.ResourceNotFound,
message: 'File not found.',
});
+ return;
}
if (node.attributes.type !== 'file') {
- return res.status(400).json({
+ res.status(400).json({
code: ApiError.BadRequest,
message: 'File not found.',
});
+ return;
}
// check if the upload is completed
@@ -99,10 +105,11 @@ filesRouter.get(
.executeTakeFirst();
if (!upload) {
- return res.status(400).json({
+ res.status(400).json({
code: ApiError.BadRequest,
message: 'Upload not completed.',
});
+ return;
}
//generate presigned url for download
@@ -123,120 +130,124 @@ filesRouter.get(
}
);
-filesRouter.post(
- '/:workspaceId',
- async (req: ColanodeRequest, res: ColanodeResponse) => {
- const workspaceId = req.params.workspaceId as string;
- const input = req.body as CreateUploadInput;
-
- if (!req.account) {
- return res.status(401).json({
- code: ApiError.Unauthorized,
- message: 'Unauthorized.',
- });
- }
-
- const workspace = await database
- .selectFrom('workspaces')
- .selectAll()
- .where('id', '=', workspaceId)
- .executeTakeFirst();
-
- if (!workspace) {
- return res.status(404).json({
- code: ApiError.ResourceNotFound,
- message: 'Workspace not found.',
- });
- }
+filesRouter.post('/:workspaceId', async (req: Request, res: Response) => {
+ const workspaceId = req.params.workspaceId as string;
+ const input = req.body as CreateUploadInput;
- const workspaceUser = await database
- .selectFrom('workspace_users')
- .selectAll()
- .where('workspace_id', '=', workspace.id)
- .where('account_id', '=', req.account.id)
- .executeTakeFirst();
-
- if (!workspaceUser) {
- return res.status(403).json({
- code: ApiError.Forbidden,
- message: 'Forbidden.',
- });
- }
-
- const node = await database
- .selectFrom('nodes')
- .selectAll()
- .where('id', '=', input.fileId)
- .executeTakeFirst();
+ if (!res.locals.account) {
+ res.status(401).json({
+ code: ApiError.Unauthorized,
+ message: 'Unauthorized.',
+ });
+ return;
+ }
- if (!node) {
- return res.status(404).json({
- code: ApiError.ResourceNotFound,
- message: 'File not found.',
- });
- }
+ const workspace = await database
+ .selectFrom('workspaces')
+ .selectAll()
+ .where('id', '=', workspaceId)
+ .executeTakeFirst();
- if (node.attributes.type !== 'file') {
- return res.status(400).json({
- code: ApiError.BadRequest,
- message: 'File not found.',
- });
- }
-
- if (node.created_by !== workspaceUser.id) {
- return res.status(403).json({
- code: ApiError.Forbidden,
- message: 'Forbidden.',
- });
- }
-
- //generate presigned url for upload
- const path = `files/${workspaceId}/${input.fileId}_${input.uploadId}${node.attributes.extension}`;
- const command = new PutObjectCommand({
- Bucket: BUCKET_NAMES.FILES,
- Key: path,
- ContentLength: node.attributes.size,
- ContentType: node.attributes.mimeType,
+ if (!workspace) {
+ res.status(404).json({
+ code: ApiError.ResourceNotFound,
+ message: 'Workspace not found.',
});
+ return;
+ }
- const expiresIn = 60 * 60 * 4; // 4 hours
- const presignedUrl = await getSignedUrl(filesStorage, command, {
- expiresIn,
+ const workspaceUser = await database
+ .selectFrom('workspace_users')
+ .selectAll()
+ .where('workspace_id', '=', workspace.id)
+ .where('account_id', '=', res.locals.account.id)
+ .executeTakeFirst();
+
+ if (!workspaceUser) {
+ res.status(403).json({
+ code: ApiError.Forbidden,
+ message: 'Forbidden.',
});
+ return;
+ }
- const data: UploadMetadata = {
- fileId: input.fileId,
- path,
- mimeType: node.attributes.mimeType,
- size: node.attributes.size,
- uploadId: input.uploadId,
- createdAt: new Date().toISOString(),
- };
+ const node = await database
+ .selectFrom('nodes')
+ .selectAll()
+ .where('id', '=', input.fileId)
+ .executeTakeFirst();
- await redis.set(input.uploadId, JSON.stringify(data), {
- EX: expiresIn,
+ if (!node) {
+ res.status(404).json({
+ code: ApiError.ResourceNotFound,
+ message: 'File not found.',
});
+ return;
+ }
- const output: CreateUploadOutput = {
- uploadId: input.uploadId,
- url: presignedUrl,
- };
+ if (node.attributes.type !== 'file') {
+ res.status(400).json({
+ code: ApiError.BadRequest,
+ message: 'File not found.',
+ });
+ return;
+ }
- res.status(200).json(output);
+ if (node.created_by !== workspaceUser.id) {
+ res.status(403).json({
+ code: ApiError.Forbidden,
+ message: 'Forbidden.',
+ });
+ return;
}
-);
+
+ //generate presigned url for upload
+ const path = `files/${workspaceId}/${input.fileId}_${input.uploadId}${node.attributes.extension}`;
+ const command = new PutObjectCommand({
+ Bucket: BUCKET_NAMES.FILES,
+ Key: path,
+ ContentLength: node.attributes.size,
+ ContentType: node.attributes.mimeType,
+ });
+
+ const expiresIn = 60 * 60 * 4; // 4 hours
+ const presignedUrl = await getSignedUrl(filesStorage, command, {
+ expiresIn,
+ });
+
+ const data: UploadMetadata = {
+ fileId: input.fileId,
+ path,
+ mimeType: node.attributes.mimeType,
+ size: node.attributes.size,
+ uploadId: input.uploadId,
+ createdAt: new Date().toISOString(),
+ };
+
+ await redis.set(input.uploadId, JSON.stringify(data), {
+ EX: expiresIn,
+ });
+
+ const output: CreateUploadOutput = {
+ uploadId: input.uploadId,
+ url: presignedUrl,
+ };
+
+ res.status(200).json(output);
+});
filesRouter.put(
'/:workspaceId/:uploadId',
- async (req: ColanodeRequest, res: ColanodeResponse) => {
+ async (req: Request, res: Response) => {
const workspaceId = req.params.workspaceId as string;
const uploadId = req.params.uploadId as string;
- if (!req.account) {
- return res.status(401).json({
+ if (!res.locals.account) {
+ res.status(401).json({
code: ApiError.Unauthorized,
message: 'Unauthorized.',
});
+ return;
}
const workspace = await database
@@ -246,32 +257,35 @@ filesRouter.put(
.executeTakeFirst();
if (!workspace) {
- return res.status(404).json({
+ res.status(404).json({
code: ApiError.ResourceNotFound,
message: 'Workspace not found.',
});
+ return;
}
const workspaceUser = await database
.selectFrom('workspace_users')
.selectAll()
.where('workspace_id', '=', workspace.id)
- .where('account_id', '=', req.account.id)
+ .where('account_id', '=', res.locals.account.id)
.executeTakeFirst();
if (!workspaceUser) {
- return res.status(403).json({
+ res.status(403).json({
code: ApiError.Forbidden,
message: 'Forbidden.',
});
+ return;
}
const metadataJson = await redis.get(uploadId);
if (!metadataJson) {
- return res.status(404).json({
+ res.status(404).json({
code: ApiError.ResourceNotFound,
message: 'Upload not found.',
});
+ return;
}
const metadata: UploadMetadata = JSON.parse(metadataJson);
@@ -282,24 +296,27 @@ filesRouter.put(
.executeTakeFirst();
if (!file) {
- return res.status(404).json({
+ res.status(404).json({
code: ApiError.ResourceNotFound,
message: 'File not found.',
});
+ return;
}
if (file.attributes.type !== 'file') {
- return res.status(400).json({
+ res.status(400).json({
code: ApiError.BadRequest,
message: 'File not found.',
});
+ return;
}
if (file.attributes.size !== metadata.size) {
- return res.status(400).json({
+ res.status(400).json({
code: ApiError.BadRequest,
message: 'Size mismatch.',
});
+ return;
}
const path = metadata.path;
@@ -314,24 +331,27 @@ filesRouter.put(
// Verify file size matches expected size
if (headObject.ContentLength !== metadata.size) {
- return res.status(400).json({
+ res.status(400).json({
code: ApiError.BadRequest,
message: 'Uploaded file size does not match expected size',
});
+ return;
}
// Verify mime type matches expected type
if (headObject.ContentType !== metadata.mimeType) {
- return res.status(400).json({
+ res.status(400).json({
code: ApiError.BadRequest,
message: 'Uploaded file type does not match expected type',
});
+ return;
}
} catch {
- return res.status(400).json({
+ res.status(400).json({
code: ApiError.BadRequest,
message: 'File upload verification failed',
});
+ return;
}
await database
diff --git a/apps/server/src/routes/nodes.ts b/apps/server/src/routes/nodes.ts
index 8172fe00..7a396c4c 100644
--- a/apps/server/src/routes/nodes.ts
+++ b/apps/server/src/routes/nodes.ts
@@ -1,23 +1,24 @@
import { GetNodeTransactionsOutput, hasViewerAccess } from '@colanode/core';
-import { Router } from 'express';
+import { Request, Response, Router } from 'express';
import { database } from '@/data/database';
import { fetchNodeRole, mapNodeTransaction } from '@/lib/nodes';
-import { ApiError, ColanodeRequest, ColanodeResponse } from '@/types/api';
+import { ApiError } from '@/types/api';
export const nodesRouter = Router();
nodesRouter.get(
'/:workspaceId/transactions/:nodeId',
- async (req: ColanodeRequest, res: ColanodeResponse) => {
+ async (req: Request, res: Response) => {
const workspaceId = req.params.workspaceId as string;
const nodeId = req.params.nodeId as string;
- if (!req.account) {
- return res.status(401).json({
+ if (!res.locals.account) {
+ res.status(401).json({
code: ApiError.Unauthorized,
message: 'Unauthorized.',
});
+ return;
}
const workspace = await database
@@ -27,32 +28,35 @@ nodesRouter.get(
.executeTakeFirst();
if (!workspace) {
- return res.status(404).json({
+ res.status(404).json({
code: ApiError.ResourceNotFound,
message: 'Workspace not found.',
});
+ return;
}
const workspaceUser = await database
.selectFrom('workspace_users')
.selectAll()
.where('workspace_id', '=', workspace.id)
- .where('account_id', '=', req.account.id)
+ .where('account_id', '=', res.locals.account.id)
.executeTakeFirst();
if (!workspaceUser) {
- return res.status(403).json({
+ res.status(403).json({
code: ApiError.Forbidden,
message: 'Forbidden.',
});
+ return;
}
const role = await fetchNodeRole(nodeId, workspaceUser.id);
if (role === null || !hasViewerAccess(role)) {
- return res.status(403).json({
+ res.status(403).json({
code: ApiError.Forbidden,
message: 'Forbidden.',
});
+ return;
}
const transactions = await database
diff --git a/apps/server/src/routes/sync.ts b/apps/server/src/routes/sync.ts
index 95468b39..3c836fe9 100644
--- a/apps/server/src/routes/sync.ts
+++ b/apps/server/src/routes/sync.ts
@@ -7,66 +7,65 @@ import {
SyncNodeTransactionsInput,
SyncNodeTransactionStatus,
} from '@colanode/core';
-import { Router } from 'express';
+import { Request, Response, Router } from 'express';
import { database } from '@/data/database';
import { SelectWorkspaceUser } from '@/data/schema';
import { nodeService } from '@/services/node-service';
-import { ApiError, ColanodeRequest, ColanodeResponse } from '@/types/api';
+import { ApiError } from '@/types/api';
export const syncRouter = Router();
-syncRouter.post(
- '/:workspaceId',
- async (req: ColanodeRequest, res: ColanodeResponse) => {
- if (!req.account) {
- return res.status(401).json({
- code: ApiError.Unauthorized,
- message: 'Unauthorized.',
- });
- }
-
- const workspaceId = req.params.workspaceId as string;
- const input = req.body as SyncNodeTransactionsInput;
+syncRouter.post('/:workspaceId', async (req: Request, res: Response) => {
+ if (!res.locals.account) {
+ res.status(401).json({
+ code: ApiError.Unauthorized,
+ message: 'Unauthorized.',
+ });
+ return;
+ }
- const workspaceUser = await database
- .selectFrom('workspace_users')
- .selectAll()
- .where('workspace_id', '=', workspaceId)
- .where('account_id', '=', req.account.id)
- .executeTakeFirst();
+ const workspaceId = req.params.workspaceId as string;
+ const input = req.body as SyncNodeTransactionsInput;
+
+ const workspaceUser = await database
+ .selectFrom('workspace_users')
+ .selectAll()
+ .where('workspace_id', '=', workspaceId)
+ .where('account_id', '=', res.locals.account.id)
+ .executeTakeFirst();
+
+ if (!workspaceUser) {
+ res.status(403).json({
+ code: ApiError.Forbidden,
+ message: 'Forbidden.',
+ });
+ return;
+ }
- if (!workspaceUser) {
- return res.status(403).json({
- code: ApiError.Forbidden,
- message: 'Forbidden.',
+ const results: SyncNodeTransactionResult[] = [];
+ for (const transaction of input.transactions) {
+ try {
+ const status = await handleLocalNodeTransaction(
+ workspaceUser,
+ transaction
+ );
+ results.push({
+ id: transaction.id,
+ status: status,
+ });
+ } catch (error) {
+ console.error('Error handling local transaction', error);
+ results.push({
+ id: transaction.id,
+ status: 'error',
});
}
-
- const results: SyncNodeTransactionResult[] = [];
- for (const transaction of input.transactions) {
- try {
- const status = await handleLocalNodeTransaction(
- workspaceUser,
- transaction
- );
- results.push({
- id: transaction.id,
- status: status,
- });
- } catch (error) {
- console.error('Error handling local transaction', error);
- results.push({
- id: transaction.id,
- status: 'error',
- });
- }
- }
-
- console.log('executed mutations', results);
- res.status(200).json({ results });
}
-);
+
+ console.log('executed mutations', results);
+ res.status(200).json({ results });
+});
const handleLocalNodeTransaction = async (
workspaceUser: SelectWorkspaceUser,
diff --git a/apps/server/src/routes/workspaces.ts b/apps/server/src/routes/workspaces.ts
index 72c616f8..a65ec39c 100644
--- a/apps/server/src/routes/workspaces.ts
+++ b/apps/server/src/routes/workspaces.ts
@@ -1,252 +1,308 @@
import {
- AccountStatus,generateId, IdType, WorkspaceCreateInput,
+ AccountStatus,
+ generateId,
+ IdType,
+ WorkspaceCreateInput,
WorkspaceOutput,
WorkspaceRole,
WorkspaceUpdateInput,
WorkspaceUserInviteResult,
WorkspaceUserRoleUpdateInput,
WorkspaceUsersInviteInput,
- WorkspaceUserStatus } from '@colanode/core';
-import { Router } from 'express';
+ WorkspaceUserStatus,
+} from '@colanode/core';
+import { Request, Response, Router } from 'express';
import { database } from '@/data/database';
import { fetchNode, mapNode, mapNodeTransaction } from '@/lib/nodes';
import { getNameFromEmail } from '@/lib/utils';
import { nodeService } from '@/services/node-service';
import { workspaceService } from '@/services/workspace-service';
-import { ApiError, ColanodeRequest, ColanodeResponse } from '@/types/api';
+import { ApiError } from '@/types/api';
export const workspacesRouter = Router();
-workspacesRouter.post(
- '/',
- async (req: ColanodeRequest, res: ColanodeResponse) => {
- const input: WorkspaceCreateInput = req.body;
+workspacesRouter.post('/', async (req: Request, res: Response) => {
+ const input: WorkspaceCreateInput = req.body;
- if (!req.account) {
- return res.status(401).json({
- code: ApiError.Unauthorized,
- message: 'Unauthorized.',
- });
- }
-
- if (!input.name) {
- return res.status(400).json({
- code: ApiError.MissingRequiredFields,
- message: 'Missing required fields.',
- });
- }
-
- const account = await database
- .selectFrom('accounts')
- .selectAll()
- .where('id', '=', req.account.id)
- .executeTakeFirst();
-
- if (!account) {
- return res.status(404).json({
- code: ApiError.ResourceNotFound,
- message: 'Account not found.',
- });
- }
-
- const output = await workspaceService.createWorkspace(account, input);
- return res.status(200).json(output);
+ if (!res.locals.account) {
+ res.status(401).json({
+ code: ApiError.Unauthorized,
+ message: 'Unauthorized.',
+ });
+ return;
}
-);
-workspacesRouter.put(
- '/:id',
- async (req: ColanodeRequest, res: ColanodeResponse) => {
- const id = req.params.id as string;
- const input: WorkspaceUpdateInput = req.body;
+ if (!input.name) {
+ res.status(400).json({
+ code: ApiError.MissingRequiredFields,
+ message: 'Missing required fields.',
+ });
+ return;
+ }
- if (!req.account) {
- return res.status(401).json({
- code: ApiError.Unauthorized,
- message: 'Unauthorized.',
- });
- }
+ const account = await database
+ .selectFrom('accounts')
+ .selectAll()
+ .where('id', '=', res.locals.account.id)
+ .executeTakeFirst();
- const workspace = await database
- .selectFrom('workspaces')
- .selectAll()
- .where('id', '=', id)
- .executeTakeFirst();
+ if (!account) {
+ res.status(404).json({
+ code: ApiError.ResourceNotFound,
+ message: 'Account not found.',
+ });
+ return;
+ }
- if (!workspace) {
- return res.status(404).json({
- code: ApiError.ResourceNotFound,
- message: 'Workspace not found.',
- });
- }
+ const output = await workspaceService.createWorkspace(account, input);
+ res.status(200).json(output);
+});
- const workspaceUser = await database
- .selectFrom('workspace_users')
- .selectAll()
- .where('workspace_id', '=', id)
- .where('account_id', '=', req.account.id)
- .executeTakeFirst();
+workspacesRouter.put('/:id', async (req: Request, res: Response) => {
+ const id = req.params.id as string;
+ const input: WorkspaceUpdateInput = req.body;
- if (!workspaceUser) {
- return res.status(403).json({
- code: ApiError.Forbidden,
- message: 'Forbidden.',
- });
- }
+ if (!res.locals.account) {
+ res.status(401).json({
+ code: ApiError.Unauthorized,
+ message: 'Unauthorized.',
+ });
+ return;
+ }
- if (workspaceUser.role !== 'owner') {
- return res.status(403).json({
- code: ApiError.Forbidden,
- message: 'Forbidden.',
- });
- }
+ const workspace = await database
+ .selectFrom('workspaces')
+ .selectAll()
+ .where('id', '=', id)
+ .executeTakeFirst();
- const updatedWorkspace = await database
- .updateTable('workspaces')
- .set({
- name: input.name,
- description: input.description,
- avatar: input.avatar,
- updated_at: new Date(),
- updated_by: req.account.id,
- })
- .where('id', '=', id)
- .returningAll()
- .executeTakeFirst();
-
- if (!updatedWorkspace) {
- return res.status(500).json({
- code: ApiError.InternalServerError,
- message: 'Internal server error.',
- });
- }
+ if (!workspace) {
+ res.status(404).json({
+ code: ApiError.ResourceNotFound,
+ message: 'Workspace not found.',
+ });
+ return;
+ }
- await nodeService.updateNode({
- nodeId: updatedWorkspace.id,
- userId: req.account.id,
- workspaceId: id,
- updater: (attributes) => {
- if (attributes.type !== 'workspace') {
- return null;
- }
+ const workspaceUser = await database
+ .selectFrom('workspace_users')
+ .selectAll()
+ .where('workspace_id', '=', id)
+ .where('account_id', '=', res.locals.account.id)
+ .executeTakeFirst();
+
+ if (!workspaceUser) {
+ res.status(403).json({
+ code: ApiError.Forbidden,
+ message: 'Forbidden.',
+ });
+ return;
+ }
- attributes.name = input.name;
- attributes.description = input.description;
- attributes.avatar = input.avatar;
+ if (workspaceUser.role !== 'owner') {
+ res.status(403).json({
+ code: ApiError.Forbidden,
+ message: 'Forbidden.',
+ });
+ return;
+ }
- return attributes;
- },
+ const updatedWorkspace = await database
+ .updateTable('workspaces')
+ .set({
+ name: input.name,
+ description: input.description,
+ avatar: input.avatar,
+ updated_at: new Date(),
+ updated_by: res.locals.account.id,
+ })
+ .where('id', '=', id)
+ .returningAll()
+ .executeTakeFirst();
+
+ if (!updatedWorkspace) {
+ res.status(500).json({
+ code: ApiError.InternalServerError,
+ message: 'Internal server error.',
});
+ return;
+ }
- const output: WorkspaceOutput = {
- id: updatedWorkspace.id,
- name: updatedWorkspace.name,
- description: updatedWorkspace.description,
- avatar: updatedWorkspace.avatar,
- versionId: updatedWorkspace.version_id,
- user: {
- id: workspaceUser.id,
- accountId: workspaceUser.account_id,
- role: workspaceUser.role,
- },
- };
+ await nodeService.updateNode({
+ nodeId: updatedWorkspace.id,
+ userId: res.locals.account.id,
+ workspaceId: id,
+ updater: (attributes) => {
+ if (attributes.type !== 'workspace') {
+ return null;
+ }
- return res.status(200).json(output);
+ attributes.name = input.name;
+ attributes.description = input.description;
+ attributes.avatar = input.avatar;
+
+ return attributes;
+ },
+ });
+
+ const output: WorkspaceOutput = {
+ id: updatedWorkspace.id,
+ name: updatedWorkspace.name,
+ description: updatedWorkspace.description,
+ avatar: updatedWorkspace.avatar,
+ versionId: updatedWorkspace.version_id,
+ user: {
+ id: workspaceUser.id,
+ accountId: workspaceUser.account_id,
+ role: workspaceUser.role,
+ },
+ };
+
+ res.status(200).json(output);
+});
+
+workspacesRouter.delete('/:id', async (req: Request, res: Response) => {
+ const id = req.params.id as string;
+
+ if (!res.locals.account) {
+ res.status(401).json({
+ code: ApiError.Unauthorized,
+ message: 'Unauthorized.',
+ });
+ return;
}
-);
-
-workspacesRouter.delete(
- '/:id',
- async (req: ColanodeRequest, res: ColanodeResponse) => {
- const id = req.params.id as string;
- if (!req.account) {
- return res.status(401).json({
- code: ApiError.Unauthorized,
- message: 'Unauthorized.',
- });
- }
+ const workspace = await database
+ .selectFrom('workspaces')
+ .selectAll()
+ .where('id', '=', id)
+ .executeTakeFirst();
- const workspace = await database
- .selectFrom('workspaces')
- .selectAll()
- .where('id', '=', id)
- .executeTakeFirst();
+ if (!workspace) {
+ res.status(404).json({
+ code: ApiError.ResourceNotFound,
+ message: 'Workspace not found.',
+ });
+ return;
+ }
- if (!workspace) {
- return res.status(404).json({
- code: ApiError.ResourceNotFound,
- message: 'Workspace not found.',
- });
- }
+ const workspaceUser = await database
+ .selectFrom('workspace_users')
+ .selectAll()
+ .where('workspace_id', '=', id)
+ .where('account_id', '=', res.locals.account.id)
+ .executeTakeFirst();
+
+ if (!workspaceUser) {
+ res.status(403).json({
+ code: ApiError.Forbidden,
+ message: 'Forbidden.',
+ });
+ return;
+ }
- const workspaceUser = await database
- .selectFrom('workspace_users')
- .selectAll()
- .where('workspace_id', '=', id)
- .where('account_id', '=', req.account.id)
- .executeTakeFirst();
+ if (workspaceUser.role !== 'owner') {
+ res.status(403).json({
+ code: ApiError.Forbidden,
+ message: 'Forbidden.',
+ });
+ return;
+ }
- if (!workspaceUser) {
- return res.status(403).json({
- code: ApiError.Forbidden,
- message: 'Forbidden.',
- });
- }
+ await database.deleteFrom('workspaces').where('id', '=', id).execute();
- if (workspaceUser.role !== 'owner') {
- return res.status(403).json({
- code: ApiError.Forbidden,
- message: 'Forbidden.',
- });
- }
+ res.status(200).json({
+ id: workspace.id,
+ });
+});
- await database.deleteFrom('workspaces').where('id', '=', id).execute();
+workspacesRouter.get('/:id', async (req: Request, res: Response) => {
+ const id = req.params.id as string;
- return res.status(200).json({
- id: workspace.id,
+ if (!res.locals.account) {
+ res.status(401).json({
+ code: ApiError.Unauthorized,
+ message: 'Unauthorized.',
});
+ return;
}
-);
-workspacesRouter.get(
- '/:id',
- async (req: ColanodeRequest, res: ColanodeResponse) => {
- const id = req.params.id as string;
+ const workspace = await database
+ .selectFrom('workspaces')
+ .selectAll()
+ .where('id', '=', id)
+ .executeTakeFirst();
- if (!req.account) {
- return res.status(401).json({
- code: ApiError.Unauthorized,
- message: 'Unauthorized.',
- });
- }
+ if (!workspace) {
+ res.status(404).json({
+ code: ApiError.ResourceNotFound,
+ message: 'Workspace not found.',
+ });
+ return;
+ }
- const workspace = await database
- .selectFrom('workspaces')
- .selectAll()
- .where('id', '=', id)
- .executeTakeFirst();
+ const workspaceUser = await database
+ .selectFrom('workspace_users')
+ .selectAll()
+ .where('workspace_id', '=', id)
+ .where('account_id', '=', res.locals.account.id)
+ .executeTakeFirst();
+
+ if (!workspaceUser) {
+ res.status(403).json({
+ code: ApiError.Forbidden,
+ message: 'Forbidden.',
+ });
+ return;
+ }
- if (!workspace) {
- return res.status(404).json({
- code: ApiError.ResourceNotFound,
- message: 'Workspace not found.',
- });
- }
+ const output: WorkspaceOutput = {
+ id: workspace.id,
+ name: workspace.name,
+ description: workspace.description,
+ avatar: workspace.avatar,
+ versionId: workspace.version_id,
+ user: {
+ id: workspaceUser.id,
+ accountId: workspaceUser.account_id,
+ role: workspaceUser.role as WorkspaceRole,
+ },
+ };
+
+ res.status(200).json(output);
+});
+
+workspacesRouter.get('/', async (req: Request, res: Response) => {
+ if (!res.locals.account) {
+ res.status(401).json({
+ code: ApiError.Unauthorized,
+ message: 'Unauthorized.',
+ });
+ return;
+ }
- const workspaceUser = await database
- .selectFrom('workspace_users')
- .selectAll()
- .where('workspace_id', '=', id)
- .where('account_id', '=', req.account.id)
- .executeTakeFirst();
+ const workspaceUsers = await database
+ .selectFrom('workspace_users')
+ .selectAll()
+ .where('account_id', '=', res.locals.account.id)
+ .execute();
+
+ const workspaceIds = workspaceUsers.map((wa) => wa.workspace_id);
+ const workspaces = await database
+ .selectFrom('workspaces')
+ .selectAll()
+ .where('id', 'in', workspaceIds)
+ .execute();
+
+ const outputs: WorkspaceOutput[] = [];
+ for (const workspace of workspaces) {
+ const workspaceUser = workspaceUsers.find(
+ (wa) => wa.workspace_id === workspace.id
+ );
if (!workspaceUser) {
- return res.status(403).json({
- code: ApiError.Forbidden,
- message: 'Forbidden.',
- });
+ continue;
}
const output: WorkspaceOutput = {
@@ -262,237 +318,190 @@ workspacesRouter.get(
},
};
- return res.status(200).json(output);
+ outputs.push(output);
}
-);
-workspacesRouter.get(
- '/',
- async (req: ColanodeRequest, res: ColanodeResponse) => {
- if (!req.account) {
- return res.status(401).json({
- code: ApiError.Unauthorized,
- message: 'Unauthorized.',
- });
- }
+ res.status(200).json(outputs);
+});
- const workspaceUsers = await database
- .selectFrom('workspace_users')
- .selectAll()
- .where('account_id', '=', req.account.id)
- .execute();
-
- const workspaceIds = workspaceUsers.map((wa) => wa.workspace_id);
- const workspaces = await database
- .selectFrom('workspaces')
- .selectAll()
- .where('id', 'in', workspaceIds)
- .execute();
+workspacesRouter.post('/:id/users', async (req: Request, res: Response) => {
+ const id = req.params.id as string;
+ const input: WorkspaceUsersInviteInput = req.body;
- const outputs: WorkspaceOutput[] = [];
- for (const workspace of workspaces) {
- const workspaceUser = workspaceUsers.find(
- (wa) => wa.workspace_id === workspace.id
- );
+ if (!input.emails || input.emails.length === 0) {
+ res.status(400).json({
+ code: ApiError.BadRequest,
+ message: 'BadRequest.',
+ });
+ return;
+ }
- if (!workspaceUser) {
- continue;
- }
+ if (!res.locals.account) {
+ res.status(401).json({
+ code: ApiError.Unauthorized,
+ message: 'Unauthorized.',
+ });
+ return;
+ }
- const output: WorkspaceOutput = {
- id: workspace.id,
- name: workspace.name,
- description: workspace.description,
- avatar: workspace.avatar,
- versionId: workspace.version_id,
- user: {
- id: workspaceUser.id,
- accountId: workspaceUser.account_id,
- role: workspaceUser.role as WorkspaceRole,
- },
- };
-
- outputs.push(output);
- }
+ const workspace = await database
+ .selectFrom('workspaces')
+ .selectAll()
+ .where('id', '=', id)
+ .executeTakeFirst();
- return res.status(200).json(outputs);
+ if (!workspace) {
+ res.status(404).json({
+ code: ApiError.ResourceNotFound,
+ message: 'Workspace not found.',
+ });
+ return;
}
-);
-workspacesRouter.post(
- '/:id/users',
- async (req: ColanodeRequest, res: ColanodeResponse) => {
- const id = req.params.id as string;
- const input: WorkspaceUsersInviteInput = req.body;
+ const workspaceUser = await database
+ .selectFrom('workspace_users')
+ .selectAll()
+ .where('workspace_id', '=', id)
+ .where('account_id', '=', res.locals.account.id)
+ .executeTakeFirst();
+
+ if (!workspaceUser) {
+ res.status(403).json({
+ code: ApiError.Forbidden,
+ message: 'Forbidden.',
+ });
+ return;
+ }
- if (!input.emails || input.emails.length === 0) {
- return res.status(400).json({
- code: ApiError.BadRequest,
- message: 'BadRequest.',
- });
- }
+ if (workspaceUser.role !== 'owner' && workspaceUser.role !== 'admin') {
+ res.status(403).json({
+ code: ApiError.Forbidden,
+ message: 'Forbidden.',
+ });
+ return;
+ }
- if (!req.account) {
- return res.status(401).json({
- code: ApiError.Unauthorized,
- message: 'Unauthorized.',
- });
- }
+ const workspaceNodeRow = await fetchNode(workspace.id);
+ if (!workspaceNodeRow) {
+ res.status(500).json({
+ code: ApiError.InternalServerError,
+ message: 'Something went wrong.',
+ });
+ return;
+ }
- const workspace = await database
- .selectFrom('workspaces')
- .selectAll()
- .where('id', '=', id)
+ const workspaceNode = mapNode(workspaceNodeRow);
+ const results: WorkspaceUserInviteResult[] = [];
+ for (const email of input.emails) {
+ let account = await database
+ .selectFrom('accounts')
+ .select(['id', 'name', 'email', 'avatar'])
+ .where('email', '=', email)
.executeTakeFirst();
- if (!workspace) {
- return res.status(404).json({
- code: ApiError.ResourceNotFound,
- message: 'Workspace not found.',
+ if (!account) {
+ account = await database
+ .insertInto('accounts')
+ .returning(['id', 'name', 'email', 'avatar'])
+ .values({
+ id: generateId(IdType.Account),
+ name: getNameFromEmail(email),
+ email: email,
+ avatar: null,
+ attrs: null,
+ password: null,
+ status: AccountStatus.Pending,
+ created_at: new Date(),
+ updated_at: null,
+ })
+ .executeTakeFirst();
+ }
+
+ if (!account) {
+ results.push({
+ email: email,
+ result: 'error',
});
+ continue;
}
- const workspaceUser = await database
+ const existingWorkspaceUser = await database
.selectFrom('workspace_users')
.selectAll()
+ .where('account_id', '=', account.id)
.where('workspace_id', '=', id)
- .where('account_id', '=', req.account.id)
.executeTakeFirst();
- if (!workspaceUser) {
- return res.status(403).json({
- code: ApiError.Forbidden,
- message: 'Forbidden.',
- });
- }
-
- if (workspaceUser.role !== 'owner' && workspaceUser.role !== 'admin') {
- return res.status(403).json({
- code: ApiError.Forbidden,
- message: 'Forbidden.',
- });
- }
-
- const workspaceNodeRow = await fetchNode(workspace.id);
- if (!workspaceNodeRow) {
- return res.status(500).json({
- code: ApiError.InternalServerError,
- message: 'Something went wrong.',
+ if (existingWorkspaceUser) {
+ results.push({
+ email: email,
+ result: 'exists',
});
+ continue;
}
- const workspaceNode = mapNode(workspaceNodeRow);
- const results: WorkspaceUserInviteResult[] = [];
- for (const email of input.emails) {
- let account = await database
- .selectFrom('accounts')
- .select(['id', 'name', 'email', 'avatar'])
- .where('email', '=', email)
- .executeTakeFirst();
-
- if (!account) {
- account = await database
- .insertInto('accounts')
- .returning(['id', 'name', 'email', 'avatar'])
- .values({
- id: generateId(IdType.Account),
- name: getNameFromEmail(email),
- email: email,
- avatar: null,
- attrs: null,
- password: null,
- status: AccountStatus.Pending,
- created_at: new Date(),
- updated_at: null,
- })
- .executeTakeFirst();
- }
-
- if (!account) {
- results.push({
- email: email,
- result: 'error',
- });
- continue;
- }
-
- const existingWorkspaceUser = await database
- .selectFrom('workspace_users')
- .selectAll()
- .where('account_id', '=', account.id)
- .where('workspace_id', '=', id)
- .executeTakeFirst();
-
- if (existingWorkspaceUser) {
- results.push({
- email: email,
- result: 'exists',
- });
- continue;
- }
-
- const userId = generateId(IdType.User);
- const newWorkspaceUser = await database
- .insertInto('workspace_users')
- .returningAll()
- .values({
- id: userId,
- account_id: account.id,
- workspace_id: id,
- role: input.role,
- created_at: new Date(),
- created_by: req.account.id,
- status: WorkspaceUserStatus.Active,
- version_id: generateId(IdType.Version),
- })
- .executeTakeFirst();
-
- if (!newWorkspaceUser) {
- results.push({
- email: email,
- result: 'error',
- });
- }
-
- await nodeService.createNode({
- nodeId: userId,
- attributes: {
- type: 'user',
- name: account.name,
- email: account.email,
- role: input.role,
- accountId: account.id,
- parentId: id,
- },
- userId: workspaceUser.id,
- workspaceId: id,
- ancestors: [workspaceNode],
- });
+ const userId = generateId(IdType.User);
+ const newWorkspaceUser = await database
+ .insertInto('workspace_users')
+ .returningAll()
+ .values({
+ id: userId,
+ account_id: account.id,
+ workspace_id: id,
+ role: input.role,
+ created_at: new Date(),
+ created_by: res.locals.account.id,
+ status: WorkspaceUserStatus.Active,
+ version_id: generateId(IdType.Version),
+ })
+ .executeTakeFirst();
+ if (!newWorkspaceUser) {
results.push({
email: email,
- result: 'success',
+ result: 'error',
});
}
- return res.status(200).json({
- results: results,
+ await nodeService.createNode({
+ nodeId: userId,
+ attributes: {
+ type: 'user',
+ name: account.name,
+ email: account.email,
+ role: input.role,
+ accountId: account.id,
+ parentId: id,
+ },
+ userId: workspaceUser.id,
+ workspaceId: id,
+ ancestors: [workspaceNode],
+ });
+
+ results.push({
+ email: email,
+ result: 'success',
});
}
-);
+
+ res.status(200).json({
+ results: results,
+ });
+});
workspacesRouter.put(
'/:id/users/:userId',
- async (req: ColanodeRequest, res: ColanodeResponse) => {
+ async (req: Request, res: Response) => {
const id = req.params.id as string;
const userId = req.params.userId as string;
const input: WorkspaceUserRoleUpdateInput = req.body;
- if (!req.account) {
- return res.status(401).json({
+ if (!res.locals.account) {
+ res.status(401).json({
code: ApiError.Unauthorized,
message: 'Unauthorized.',
});
+ return;
}
const workspace = await database
@@ -502,34 +511,37 @@ workspacesRouter.put(
.executeTakeFirst();
if (!workspace) {
- return res.status(404).json({
+ res.status(404).json({
code: ApiError.ResourceNotFound,
message: 'Workspace not found.',
});
+ return;
}
const currentWorkspaceUser = await database
.selectFrom('workspace_users')
.selectAll()
.where('workspace_id', '=', id)
- .where('account_id', '=', req.account.id)
+ .where('account_id', '=', res.locals.account.id)
.executeTakeFirst();
if (!currentWorkspaceUser) {
- return res.status(403).json({
+ res.status(403).json({
code: ApiError.Forbidden,
message: 'Forbidden.',
});
+ return;
}
if (
currentWorkspaceUser.role !== 'owner' &&
currentWorkspaceUser.role !== 'admin'
) {
- return res.status(403).json({
+ res.status(403).json({
code: ApiError.Forbidden,
message: 'Forbidden.',
});
+ return;
}
const workspaceUserToUpdate = await database
@@ -539,10 +551,11 @@ workspacesRouter.put(
.executeTakeFirst();
if (!workspaceUserToUpdate) {
- return res.status(404).json({
+ res.status(404).json({
code: ApiError.ResourceNotFound,
message: 'NotFound.',
});
+ return;
}
const user = await database
@@ -552,10 +565,11 @@ workspacesRouter.put(
.executeTakeFirst();
if (!user) {
- return res.status(404).json({
+ res.status(404).json({
code: ApiError.ResourceNotFound,
message: 'NotFound.',
});
+ return;
}
await database
@@ -584,13 +598,14 @@ workspacesRouter.put(
});
if (!updateUserOutput) {
- return res.status(500).json({
+ res.status(500).json({
code: ApiError.InternalServerError,
message: 'Something went wrong.',
});
+ return;
}
- return res.status(200).json({
+ res.status(200).json({
transaction: mapNodeTransaction(updateUserOutput.transaction),
});
}
diff --git a/apps/server/src/types/api.ts b/apps/server/src/types/api.ts
index c714b7f5..4160fe4d 100644
--- a/apps/server/src/types/api.ts
+++ b/apps/server/src/types/api.ts
@@ -1,5 +1,3 @@
-import { NextFunction,Request, Response } from 'express';
-
export enum ApiError {
GoogleAuthFailed = 'GoogleAuthFailed',
UserPendingActivation = 'UserPendingActivation',
@@ -17,11 +15,3 @@ export type ColanodeRequestAccount = {
id: string;
deviceId: string;
};
-
-export type ColanodeRequest = Request & {
- account?: ColanodeRequestAccount;
-};
-
-export type ColanodeResponse = Response;
-
-export type ColanodeNextFunction = NextFunction;
diff --git a/package-lock.json b/package-lock.json
index 10a4d74b..2aa79316 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -144,7 +144,7 @@
"bullmq": "^5.30.1",
"cors": "^2.8.5",
"dotenv": "^16.4.5",
- "express": "^4.21.1",
+ "express": "^5.0.1",
"js-sha256": "^0.11.0",
"kafkajs": "^2.2.4",
"kysely": "^0.27.4",
@@ -161,7 +161,7 @@
"devDependencies": {
"@types/bcrypt": "^5.0.2",
"@types/cors": "^2.8.17",
- "@types/express": "^4.17.21",
+ "@types/express": "^5.0.0",
"@types/multer": "^1.4.12",
"@types/node": "^22.10.1",
"@types/nodemailer": "^6.4.17",
@@ -172,30 +172,363 @@
"tsx": "^4.19.2"
}
},
- "apps/server/node_modules/@types/express": {
- "version": "4.17.21",
- "resolved": "https://registry.npmjs.org/@types/express/-/express-4.17.21.tgz",
- "integrity": "sha512-ejlPM315qwLpaQlQDTjPdsUFSc6ZsP4AN6AlWnogPjQ7CVi7PYF3YVz+CY3jE2pwYf7E/7HlDAN0rV2GxTG0HQ==",
- "dev": true,
+ "apps/server/node_modules/accepts": {
+ "version": "2.0.0",
+ "resolved": "https://registry.npmjs.org/accepts/-/accepts-2.0.0.tgz",
+ "integrity": "sha512-5cvg6CtKwfgdmVqY1WIiXKc3Q1bkRqGLi+2W/6ao+6Y7gu/RCwRuAhGEzh5B4KlszSuTLgZYuqFqo5bImjNKng==",
"license": "MIT",
"dependencies": {
- "@types/body-parser": "*",
- "@types/express-serve-static-core": "^4.17.33",
- "@types/qs": "*",
- "@types/serve-static": "*"
+ "mime-types": "^3.0.0",
+ "negotiator": "^1.0.0"
+ },
+ "engines": {
+ "node": ">= 0.6"
}
},
- "apps/server/node_modules/@types/express-serve-static-core": {
- "version": "4.19.6",
- "resolved": "https://registry.npmjs.org/@types/express-serve-static-core/-/express-serve-static-core-4.19.6.tgz",
- "integrity": "sha512-N4LZ2xG7DatVqhCZzOGb1Yi5lMbXSZcmdLDe9EzSndPV2HpWYWzRbaerl2n27irrm94EPpprqa8KpskPT085+A==",
- "dev": true,
+ "apps/server/node_modules/body-parser": {
+ "version": "2.0.2",
+ "resolved": "https://registry.npmjs.org/body-parser/-/body-parser-2.0.2.tgz",
+ "integrity": "sha512-SNMk0OONlQ01uk8EPeiBvTW7W4ovpL5b1O3t1sjpPgfxOQ6BqQJ6XjxinDPR79Z6HdcD5zBBwr5ssiTlgdNztQ==",
"license": "MIT",
"dependencies": {
- "@types/node": "*",
- "@types/qs": "*",
- "@types/range-parser": "*",
- "@types/send": "*"
+ "bytes": "3.1.2",
+ "content-type": "~1.0.5",
+ "debug": "3.1.0",
+ "destroy": "1.2.0",
+ "http-errors": "2.0.0",
+ "iconv-lite": "0.5.2",
+ "on-finished": "2.4.1",
+ "qs": "6.13.0",
+ "raw-body": "^3.0.0",
+ "type-is": "~1.6.18"
+ },
+ "engines": {
+ "node": ">=18"
+ }
+ },
+ "apps/server/node_modules/body-parser/node_modules/debug": {
+ "version": "3.1.0",
+ "resolved": "https://registry.npmjs.org/debug/-/debug-3.1.0.tgz",
+ "integrity": "sha512-OX8XqP7/1a9cqkxYw2yXss15f26NKWBpDXQd0/uK/KPqdQhxbPa994hnzjcE2VqQpDslf55723cKPUOGSmMY3g==",
+ "license": "MIT",
+ "dependencies": {
+ "ms": "2.0.0"
+ }
+ },
+ "apps/server/node_modules/body-parser/node_modules/ms": {
+ "version": "2.0.0",
+ "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz",
+ "integrity": "sha512-Tpp60P6IUJDTuOq/5Z8cdskzJujfwqfOTkrwIwj7IRISpnkJnT6SyJ4PCPnGMoFjC9ddhal5KVIYtAt97ix05A==",
+ "license": "MIT"
+ },
+ "apps/server/node_modules/content-disposition": {
+ "version": "1.0.0",
+ "resolved": "https://registry.npmjs.org/content-disposition/-/content-disposition-1.0.0.tgz",
+ "integrity": "sha512-Au9nRL8VNUut/XSzbQA38+M78dzP4D+eqg3gfJHMIHHYa3bg067xj1KxMUWj+VULbiZMowKngFFbKczUrNJ1mg==",
+ "license": "MIT",
+ "dependencies": {
+ "safe-buffer": "5.2.1"
+ },
+ "engines": {
+ "node": ">= 0.6"
+ }
+ },
+ "apps/server/node_modules/cookie-signature": {
+ "version": "1.2.2",
+ "resolved": "https://registry.npmjs.org/cookie-signature/-/cookie-signature-1.2.2.tgz",
+ "integrity": "sha512-D76uU73ulSXrD1UXF4KE2TMxVVwhsnCgfAyTg9k8P6KGZjlXKrOLe4dJQKI3Bxi5wjesZoFXJWElNWBjPZMbhg==",
+ "license": "MIT",
+ "engines": {
+ "node": ">=6.6.0"
+ }
+ },
+ "apps/server/node_modules/debug": {
+ "version": "4.3.6",
+ "resolved": "https://registry.npmjs.org/debug/-/debug-4.3.6.tgz",
+ "integrity": "sha512-O/09Bd4Z1fBrU4VzkhFqVgpPzaGbw6Sm9FEkBT1A/YBXQFGuuSxa1dN2nxgxS34JmKXqYx8CZAwEVoJFImUXIg==",
+ "license": "MIT",
+ "dependencies": {
+ "ms": "2.1.2"
+ },
+ "engines": {
+ "node": ">=6.0"
+ },
+ "peerDependenciesMeta": {
+ "supports-color": {
+ "optional": true
+ }
+ }
+ },
+ "apps/server/node_modules/debug/node_modules/ms": {
+ "version": "2.1.2",
+ "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz",
+ "integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==",
+ "license": "MIT"
+ },
+ "apps/server/node_modules/express": {
+ "version": "5.0.1",
+ "resolved": "https://registry.npmjs.org/express/-/express-5.0.1.tgz",
+ "integrity": "sha512-ORF7g6qGnD+YtUG9yx4DFoqCShNMmUKiXuT5oWMHiOvt/4WFbHC6yCwQMTSBMno7AqntNCAzzcnnjowRkTL9eQ==",
+ "license": "MIT",
+ "dependencies": {
+ "accepts": "^2.0.0",
+ "body-parser": "^2.0.1",
+ "content-disposition": "^1.0.0",
+ "content-type": "~1.0.4",
+ "cookie": "0.7.1",
+ "cookie-signature": "^1.2.1",
+ "debug": "4.3.6",
+ "depd": "2.0.0",
+ "encodeurl": "~2.0.0",
+ "escape-html": "~1.0.3",
+ "etag": "~1.8.1",
+ "finalhandler": "^2.0.0",
+ "fresh": "2.0.0",
+ "http-errors": "2.0.0",
+ "merge-descriptors": "^2.0.0",
+ "methods": "~1.1.2",
+ "mime-types": "^3.0.0",
+ "on-finished": "2.4.1",
+ "once": "1.4.0",
+ "parseurl": "~1.3.3",
+ "proxy-addr": "~2.0.7",
+ "qs": "6.13.0",
+ "range-parser": "~1.2.1",
+ "router": "^2.0.0",
+ "safe-buffer": "5.2.1",
+ "send": "^1.1.0",
+ "serve-static": "^2.1.0",
+ "setprototypeof": "1.2.0",
+ "statuses": "2.0.1",
+ "type-is": "^2.0.0",
+ "utils-merge": "1.0.1",
+ "vary": "~1.1.2"
+ },
+ "engines": {
+ "node": ">= 18"
+ }
+ },
+ "apps/server/node_modules/express/node_modules/type-is": {
+ "version": "2.0.0",
+ "resolved": "https://registry.npmjs.org/type-is/-/type-is-2.0.0.tgz",
+ "integrity": "sha512-gd0sGezQYCbWSbkZr75mln4YBidWUN60+devscpLF5mtRDUpiaTvKpBNrdaCvel1NdR2k6vclXybU5fBd2i+nw==",
+ "license": "MIT",
+ "dependencies": {
+ "content-type": "^1.0.5",
+ "media-typer": "^1.1.0",
+ "mime-types": "^3.0.0"
+ },
+ "engines": {
+ "node": ">= 0.6"
+ }
+ },
+ "apps/server/node_modules/finalhandler": {
+ "version": "2.0.0",
+ "resolved": "https://registry.npmjs.org/finalhandler/-/finalhandler-2.0.0.tgz",
+ "integrity": "sha512-MX6Zo2adDViYh+GcxxB1dpO43eypOGUOL12rLCOTMQv/DfIbpSJUy4oQIIZhVZkH9e+bZWKMon0XHFEju16tkQ==",
+ "license": "MIT",
+ "dependencies": {
+ "debug": "2.6.9",
+ "encodeurl": "~1.0.2",
+ "escape-html": "~1.0.3",
+ "on-finished": "2.4.1",
+ "parseurl": "~1.3.3",
+ "statuses": "2.0.1",
+ "unpipe": "~1.0.0"
+ },
+ "engines": {
+ "node": ">= 0.8"
+ }
+ },
+ "apps/server/node_modules/finalhandler/node_modules/debug": {
+ "version": "2.6.9",
+ "resolved": "https://registry.npmjs.org/debug/-/debug-2.6.9.tgz",
+ "integrity": "sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA==",
+ "license": "MIT",
+ "dependencies": {
+ "ms": "2.0.0"
+ }
+ },
+ "apps/server/node_modules/finalhandler/node_modules/encodeurl": {
+ "version": "1.0.2",
+ "resolved": "https://registry.npmjs.org/encodeurl/-/encodeurl-1.0.2.tgz",
+ "integrity": "sha512-TPJXq8JqFaVYm2CWmPvnP2Iyo4ZSM7/QKcSmuMLDObfpH5fi7RUGmd/rTDf+rut/saiDiQEeVTNgAmJEdAOx0w==",
+ "license": "MIT",
+ "engines": {
+ "node": ">= 0.8"
+ }
+ },
+ "apps/server/node_modules/finalhandler/node_modules/ms": {
+ "version": "2.0.0",
+ "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz",
+ "integrity": "sha512-Tpp60P6IUJDTuOq/5Z8cdskzJujfwqfOTkrwIwj7IRISpnkJnT6SyJ4PCPnGMoFjC9ddhal5KVIYtAt97ix05A==",
+ "license": "MIT"
+ },
+ "apps/server/node_modules/fresh": {
+ "version": "2.0.0",
+ "resolved": "https://registry.npmjs.org/fresh/-/fresh-2.0.0.tgz",
+ "integrity": "sha512-Rx/WycZ60HOaqLKAi6cHRKKI7zxWbJ31MhntmtwMoaTeF7XFH9hhBp8vITaMidfljRQ6eYWCKkaTK+ykVJHP2A==",
+ "license": "MIT",
+ "engines": {
+ "node": ">= 0.8"
+ }
+ },
+ "apps/server/node_modules/iconv-lite": {
+ "version": "0.5.2",
+ "resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.5.2.tgz",
+ "integrity": "sha512-kERHXvpSaB4aU3eANwidg79K8FlrN77m8G9V+0vOR3HYaRifrlwMEpT7ZBJqLSEIHnEgJTHcWK82wwLwwKwtag==",
+ "license": "MIT",
+ "dependencies": {
+ "safer-buffer": ">= 2.1.2 < 3"
+ },
+ "engines": {
+ "node": ">=0.10.0"
+ }
+ },
+ "apps/server/node_modules/media-typer": {
+ "version": "1.1.0",
+ "resolved": "https://registry.npmjs.org/media-typer/-/media-typer-1.1.0.tgz",
+ "integrity": "sha512-aisnrDP4GNe06UcKFnV5bfMNPBUw4jsLGaWwWfnH3v02GnBuXX2MCVn5RbrWo0j3pczUilYblq7fQ7Nw2t5XKw==",
+ "license": "MIT",
+ "engines": {
+ "node": ">= 0.8"
+ }
+ },
+ "apps/server/node_modules/merge-descriptors": {
+ "version": "2.0.0",
+ "resolved": "https://registry.npmjs.org/merge-descriptors/-/merge-descriptors-2.0.0.tgz",
+ "integrity": "sha512-Snk314V5ayFLhp3fkUREub6WtjBfPdCPY1Ln8/8munuLuiYhsABgBVWsozAG+MWMbVEvcdcpbi9R7ww22l9Q3g==",
+ "license": "MIT",
+ "engines": {
+ "node": ">=18"
+ },
+ "funding": {
+ "url": "https://github.com/sponsors/sindresorhus"
+ }
+ },
+ "apps/server/node_modules/mime-db": {
+ "version": "1.53.0",
+ "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.53.0.tgz",
+ "integrity": "sha512-oHlN/w+3MQ3rba9rqFr6V/ypF10LSkdwUysQL7GkXoTgIWeV+tcXGA852TBxH+gsh8UWoyhR1hKcoMJTuWflpg==",
+ "license": "MIT",
+ "engines": {
+ "node": ">= 0.6"
+ }
+ },
+ "apps/server/node_modules/mime-types": {
+ "version": "3.0.0",
+ "resolved": "https://registry.npmjs.org/mime-types/-/mime-types-3.0.0.tgz",
+ "integrity": "sha512-XqoSHeCGjVClAmoGFG3lVFqQFRIrTVw2OH3axRqAcfaw+gHWIfnASS92AV+Rl/mk0MupgZTRHQOjxY6YVnzK5w==",
+ "license": "MIT",
+ "dependencies": {
+ "mime-db": "^1.53.0"
+ },
+ "engines": {
+ "node": ">= 0.6"
+ }
+ },
+ "apps/server/node_modules/negotiator": {
+ "version": "1.0.0",
+ "resolved": "https://registry.npmjs.org/negotiator/-/negotiator-1.0.0.tgz",
+ "integrity": "sha512-8Ofs/AUQh8MaEcrlq5xOX0CQ9ypTF5dl78mjlMNfOK08fzpgTHQRQPBxcPlEtIw0yRpws+Zo/3r+5WRby7u3Gg==",
+ "license": "MIT",
+ "engines": {
+ "node": ">= 0.6"
+ }
+ },
+ "apps/server/node_modules/raw-body": {
+ "version": "3.0.0",
+ "resolved": "https://registry.npmjs.org/raw-body/-/raw-body-3.0.0.tgz",
+ "integrity": "sha512-RmkhL8CAyCRPXCE28MMH0z2PNWQBNk2Q09ZdxM9IOOXwxwZbN+qbWaatPkdkWIKL2ZVDImrN/pK5HTRz2PcS4g==",
+ "license": "MIT",
+ "dependencies": {
+ "bytes": "3.1.2",
+ "http-errors": "2.0.0",
+ "iconv-lite": "0.6.3",
+ "unpipe": "1.0.0"
+ },
+ "engines": {
+ "node": ">= 0.8"
+ }
+ },
+ "apps/server/node_modules/raw-body/node_modules/iconv-lite": {
+ "version": "0.6.3",
+ "resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.6.3.tgz",
+ "integrity": "sha512-4fCk79wshMdzMp2rH06qWrJE4iolqLhCUH+OiuIgU++RB0+94NlDL81atO7GX55uUKueo0txHNtvEyI6D7WdMw==",
+ "license": "MIT",
+ "dependencies": {
+ "safer-buffer": ">= 2.1.2 < 3.0.0"
+ },
+ "engines": {
+ "node": ">=0.10.0"
+ }
+ },
+ "apps/server/node_modules/send": {
+ "version": "1.1.0",
+ "resolved": "https://registry.npmjs.org/send/-/send-1.1.0.tgz",
+ "integrity": "sha512-v67WcEouB5GxbTWL/4NeToqcZiAWEq90N888fczVArY8A79J0L4FD7vj5hm3eUMua5EpoQ59wa/oovY6TLvRUA==",
+ "license": "MIT",
+ "dependencies": {
+ "debug": "^4.3.5",
+ "destroy": "^1.2.0",
+ "encodeurl": "^2.0.0",
+ "escape-html": "^1.0.3",
+ "etag": "^1.8.1",
+ "fresh": "^0.5.2",
+ "http-errors": "^2.0.0",
+ "mime-types": "^2.1.35",
+ "ms": "^2.1.3",
+ "on-finished": "^2.4.1",
+ "range-parser": "^1.2.1",
+ "statuses": "^2.0.1"
+ },
+ "engines": {
+ "node": ">= 18"
+ }
+ },
+ "apps/server/node_modules/send/node_modules/fresh": {
+ "version": "0.5.2",
+ "resolved": "https://registry.npmjs.org/fresh/-/fresh-0.5.2.tgz",
+ "integrity": "sha512-zJ2mQYM18rEFOudeV4GShTGIQ7RbzA7ozbU9I/XBpm7kqgMywgmylMwXHxZJmkVoYkna9d2pVXVXPdYTP9ej8Q==",
+ "license": "MIT",
+ "engines": {
+ "node": ">= 0.6"
+ }
+ },
+ "apps/server/node_modules/send/node_modules/mime-db": {
+ "version": "1.52.0",
+ "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.52.0.tgz",
+ "integrity": "sha512-sPU4uV7dYlvtWJxwwxHD0PuihVNiE7TyAbQ5SWxDCB9mUYvOgroQOwYQQOKPJ8CIbE+1ETVlOoK1UC2nU3gYvg==",
+ "license": "MIT",
+ "engines": {
+ "node": ">= 0.6"
+ }
+ },
+ "apps/server/node_modules/send/node_modules/mime-types": {
+ "version": "2.1.35",
+ "resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.35.tgz",
+ "integrity": "sha512-ZDY+bPm5zTTF+YpCrAU9nK0UgICYPT0QtT1NZWFv4s++TNkcgVaT0g6+4R2uI4MjQjzysHB1zxuWL50hzaeXiw==",
+ "license": "MIT",
+ "dependencies": {
+ "mime-db": "1.52.0"
+ },
+ "engines": {
+ "node": ">= 0.6"
+ }
+ },
+ "apps/server/node_modules/serve-static": {
+ "version": "2.1.0",
+ "resolved": "https://registry.npmjs.org/serve-static/-/serve-static-2.1.0.tgz",
+ "integrity": "sha512-A3We5UfEjG8Z7VkDv6uItWw6HY2bBSBJT1KtVESn6EOoOr2jAxNhxWCLY3jDE2WcuHXByWju74ck3ZgLwL8xmA==",
+ "license": "MIT",
+ "dependencies": {
+ "encodeurl": "^2.0.0",
+ "escape-html": "^1.0.3",
+ "parseurl": "^1.3.3",
+ "send": "^1.0.0"
+ },
+ "engines": {
+ "node": ">= 18"
}
},
"node_modules/@alloc/quick-lru": {
@@ -6789,6 +7122,7 @@
"version": "1.3.8",
"resolved": "https://registry.npmjs.org/accepts/-/accepts-1.3.8.tgz",
"integrity": "sha512-PYAthTa2m2VKxuvSD3DPC/Gy+U+sOA1LAuT8mkmRuvw+NACSaeXEQ+NHcVF7rONl6qcaxV3Uuemwawk+7+SJLw==",
+ "dev": true,
"license": "MIT",
"dependencies": {
"mime-types": "~2.1.34",
@@ -7019,6 +7353,7 @@
"version": "1.1.1",
"resolved": "https://registry.npmjs.org/array-flatten/-/array-flatten-1.1.1.tgz",
"integrity": "sha512-PCVAQswWemu6UdxsDFFX/+gVeYqKAod3D3UVm91jHwynguOwAvYPhx8nNlM++NqRcK6CxxpUafjmhIdKiHibqg==",
+ "dev": true,
"license": "MIT"
},
"node_modules/array-includes": {
@@ -7421,6 +7756,7 @@
"version": "1.20.3",
"resolved": "https://registry.npmjs.org/body-parser/-/body-parser-1.20.3.tgz",
"integrity": "sha512-7rAxByjUMqQ3/bHJy7D6OGXvx/MMc4IqBn/X0fcM1QUcAItpZrBEYhWGem+tzXH90c+G01ypMcYJBO9Y30203g==",
+ "dev": true,
"license": "MIT",
"dependencies": {
"bytes": "3.1.2",
@@ -7445,6 +7781,7 @@
"version": "2.6.9",
"resolved": "https://registry.npmjs.org/debug/-/debug-2.6.9.tgz",
"integrity": "sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA==",
+ "dev": true,
"license": "MIT",
"dependencies": {
"ms": "2.0.0"
@@ -7454,6 +7791,7 @@
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz",
"integrity": "sha512-Tpp60P6IUJDTuOq/5Z8cdskzJujfwqfOTkrwIwj7IRISpnkJnT6SyJ4PCPnGMoFjC9ddhal5KVIYtAt97ix05A==",
+ "dev": true,
"license": "MIT"
},
"node_modules/boolean": {
@@ -8282,6 +8620,7 @@
"version": "0.5.4",
"resolved": "https://registry.npmjs.org/content-disposition/-/content-disposition-0.5.4.tgz",
"integrity": "sha512-FveZTNuGw04cxlAiWbzi6zTAL/lhehaWbTtgluJh4/E95DqMwTmha3KZN1aAWA8cFIhHzMZUvLevkw5Rqk+tSQ==",
+ "dev": true,
"license": "MIT",
"dependencies": {
"safe-buffer": "5.2.1"
@@ -8312,6 +8651,7 @@
"version": "1.0.6",
"resolved": "https://registry.npmjs.org/cookie-signature/-/cookie-signature-1.0.6.tgz",
"integrity": "sha512-QADzlaHc8icV8I7vbaJXJwod9HWYp8uCqf1xa4OfNu1T7JVxQIrUgOWtHdNDtPiywmFbiS12VjotIXLrKM3orQ==",
+ "dev": true,
"license": "MIT"
},
"node_modules/core-util-is": {
@@ -10312,6 +10652,7 @@
"version": "4.21.1",
"resolved": "https://registry.npmjs.org/express/-/express-4.21.1.tgz",
"integrity": "sha512-YSFlK1Ee0/GC8QaO91tHcDxJiE/X4FbpAyQWkxAvG6AXCuR65YzK8ua6D9hvi/TzUfZMpc+BwuM1IPw8fmQBiQ==",
+ "dev": true,
"license": "MIT",
"dependencies": {
"accepts": "~1.3.8",
@@ -10392,6 +10733,7 @@
"version": "2.6.9",
"resolved": "https://registry.npmjs.org/debug/-/debug-2.6.9.tgz",
"integrity": "sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA==",
+ "dev": true,
"license": "MIT",
"dependencies": {
"ms": "2.0.0"
@@ -10401,6 +10743,7 @@
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz",
"integrity": "sha512-Tpp60P6IUJDTuOq/5Z8cdskzJujfwqfOTkrwIwj7IRISpnkJnT6SyJ4PCPnGMoFjC9ddhal5KVIYtAt97ix05A==",
+ "dev": true,
"license": "MIT"
},
"node_modules/extract-zip": {
@@ -10613,6 +10956,7 @@
"version": "1.3.1",
"resolved": "https://registry.npmjs.org/finalhandler/-/finalhandler-1.3.1.tgz",
"integrity": "sha512-6BN9trH7bp3qvnrRyzsBz+g3lZxTNZTbVO2EV1CS0WIcDbawYVdYvGflME/9QP0h0pYlCDBCTjYa9nZzMDpyxQ==",
+ "dev": true,
"license": "MIT",
"dependencies": {
"debug": "2.6.9",
@@ -10631,6 +10975,7 @@
"version": "2.6.9",
"resolved": "https://registry.npmjs.org/debug/-/debug-2.6.9.tgz",
"integrity": "sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA==",
+ "dev": true,
"license": "MIT",
"dependencies": {
"ms": "2.0.0"
@@ -10640,6 +10985,7 @@
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz",
"integrity": "sha512-Tpp60P6IUJDTuOq/5Z8cdskzJujfwqfOTkrwIwj7IRISpnkJnT6SyJ4PCPnGMoFjC9ddhal5KVIYtAt97ix05A==",
+ "dev": true,
"license": "MIT"
},
"node_modules/find-up": {
@@ -10788,6 +11134,7 @@
"version": "0.5.2",
"resolved": "https://registry.npmjs.org/fresh/-/fresh-0.5.2.tgz",
"integrity": "sha512-zJ2mQYM18rEFOudeV4GShTGIQ7RbzA7ozbU9I/XBpm7kqgMywgmylMwXHxZJmkVoYkna9d2pVXVXPdYTP9ej8Q==",
+ "dev": true,
"license": "MIT",
"engines": {
"node": ">= 0.6"
@@ -11516,6 +11863,7 @@
"version": "0.4.24",
"resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.4.24.tgz",
"integrity": "sha512-v3MXnZAcvnywkTUEZomIActle7RXXeedOR31wwl7VlyoXO4Qi9arvSenNQWne1TcRwhCL1HwLI21bEqdpj8/rA==",
+ "dev": true,
"license": "MIT",
"dependencies": {
"safer-buffer": ">= 2.1.2 < 3"
@@ -12011,6 +12359,12 @@
"node": ">=0.10.0"
}
},
+ "node_modules/is-promise": {
+ "version": "4.0.0",
+ "resolved": "https://registry.npmjs.org/is-promise/-/is-promise-4.0.0.tgz",
+ "integrity": "sha512-hvpoI6korhJMnej285dSg6nu1+e6uxs7zG3BYAm5byqDsgJNWwxzM6z6iZiAgQR4TJ30JmBTOwqZUw3WlyH3AQ==",
+ "license": "MIT"
+ },
"node_modules/is-regex": {
"version": "1.2.0",
"resolved": "https://registry.npmjs.org/is-regex/-/is-regex-1.2.0.tgz",
@@ -12872,6 +13226,7 @@
"version": "1.0.3",
"resolved": "https://registry.npmjs.org/merge-descriptors/-/merge-descriptors-1.0.3.tgz",
"integrity": "sha512-gaNvAS7TZ897/rVaZ0nMtAyxNyi/pdbjbAwUpFQpN70GqnVfOiXpeUUMKRBmzXaSQ8DdTX4/0ms62r2K+hE6mQ==",
+ "dev": true,
"license": "MIT",
"funding": {
"url": "https://github.com/sponsors/sindresorhus"
@@ -12912,6 +13267,7 @@
"version": "1.6.0",
"resolved": "https://registry.npmjs.org/mime/-/mime-1.6.0.tgz",
"integrity": "sha512-x0Vn8spI+wuJ1O6S7gnbaQg8Pxh4NNHb7KSINmEWKiPE4RKOplvijn+NkmYmmRgP68mc70j2EbeTFRsrswaQeg==",
+ "dev": true,
"license": "MIT",
"bin": {
"mime": "cli.js"
@@ -13208,6 +13564,7 @@
"version": "0.6.3",
"resolved": "https://registry.npmjs.org/negotiator/-/negotiator-0.6.3.tgz",
"integrity": "sha512-+EUsqGPLsM+j/zdChZjsnX51g4XrHFOIXwfnCVPGlQk/k5giakcKsuxCObBRu6DSm9opw/O6slWbJdghQM4bBg==",
+ "dev": true,
"license": "MIT",
"engines": {
"node": ">= 0.6"
@@ -13987,6 +14344,7 @@
"version": "0.1.10",
"resolved": "https://registry.npmjs.org/path-to-regexp/-/path-to-regexp-0.1.10.tgz",
"integrity": "sha512-7lf7qcQidTku0Gu3YDPc8DJ1q7OOucfa/BSsIwjuh56VU7katFvuM8hULfkwB3Fns/rsVF7PwPKVw1sl5KQS9w==",
+ "dev": true,
"license": "MIT"
},
"node_modules/path-type": {
@@ -15086,6 +15444,7 @@
"version": "2.5.2",
"resolved": "https://registry.npmjs.org/raw-body/-/raw-body-2.5.2.tgz",
"integrity": "sha512-8zGqypfENjCIqGhgXToC8aB2r7YrBX+AQAfIPs/Mlk+BtPTztOvTS01NRW/3Eh60J+a48lt8qsCzirQ6loCVfA==",
+ "dev": true,
"license": "MIT",
"dependencies": {
"bytes": "3.1.2",
@@ -15925,6 +16284,39 @@
"license": "MIT",
"peer": true
},
+ "node_modules/router": {
+ "version": "2.0.0",
+ "resolved": "https://registry.npmjs.org/router/-/router-2.0.0.tgz",
+ "integrity": "sha512-dIM5zVoG8xhC6rnSN8uoAgFARwTE7BQs8YwHEvK0VCmfxQXMaOuA1uiR1IPwsW7JyK5iTt7Od/TC9StasS2NPQ==",
+ "license": "MIT",
+ "dependencies": {
+ "array-flatten": "3.0.0",
+ "is-promise": "4.0.0",
+ "methods": "~1.1.2",
+ "parseurl": "~1.3.3",
+ "path-to-regexp": "^8.0.0",
+ "setprototypeof": "1.2.0",
+ "utils-merge": "1.0.1"
+ },
+ "engines": {
+ "node": ">= 0.10"
+ }
+ },
+ "node_modules/router/node_modules/array-flatten": {
+ "version": "3.0.0",
+ "resolved": "https://registry.npmjs.org/array-flatten/-/array-flatten-3.0.0.tgz",
+ "integrity": "sha512-zPMVc3ZYlGLNk4mpK1NzP2wg0ml9t7fUgDsayR5Y5rSzxQilzR9FGu/EH2jQOcKSAeAfWeylyW8juy3OkWRvNA==",
+ "license": "MIT"
+ },
+ "node_modules/router/node_modules/path-to-regexp": {
+ "version": "8.2.0",
+ "resolved": "https://registry.npmjs.org/path-to-regexp/-/path-to-regexp-8.2.0.tgz",
+ "integrity": "sha512-TdrF7fW9Rphjq4RjrW0Kp2AW0Ahwu9sRGTkS6bvDi0SCwZlEZYmcfDbEsTz8RVk0EHIS/Vd1bv3JhG+1xZuAyQ==",
+ "license": "MIT",
+ "engines": {
+ "node": ">=16"
+ }
+ },
"node_modules/run-parallel": {
"version": "1.2.0",
"resolved": "https://registry.npmjs.org/run-parallel/-/run-parallel-1.2.0.tgz",
@@ -16066,6 +16458,7 @@
"version": "0.19.0",
"resolved": "https://registry.npmjs.org/send/-/send-0.19.0.tgz",
"integrity": "sha512-dW41u5VfLXu8SJh5bwRmyYUbAoSB3c9uQh6L8h/KtsFREPWpbX1lrljJo186Jc4nmci/sGUZ9a0a0J2zgfq2hw==",
+ "dev": true,
"license": "MIT",
"dependencies": {
"debug": "2.6.9",
@@ -16090,6 +16483,7 @@
"version": "2.6.9",
"resolved": "https://registry.npmjs.org/debug/-/debug-2.6.9.tgz",
"integrity": "sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA==",
+ "dev": true,
"license": "MIT",
"dependencies": {
"ms": "2.0.0"
@@ -16099,12 +16493,14 @@
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz",
"integrity": "sha512-Tpp60P6IUJDTuOq/5Z8cdskzJujfwqfOTkrwIwj7IRISpnkJnT6SyJ4PCPnGMoFjC9ddhal5KVIYtAt97ix05A==",
+ "dev": true,
"license": "MIT"
},
"node_modules/send/node_modules/encodeurl": {
"version": "1.0.2",
"resolved": "https://registry.npmjs.org/encodeurl/-/encodeurl-1.0.2.tgz",
"integrity": "sha512-TPJXq8JqFaVYm2CWmPvnP2Iyo4ZSM7/QKcSmuMLDObfpH5fi7RUGmd/rTDf+rut/saiDiQEeVTNgAmJEdAOx0w==",
+ "dev": true,
"license": "MIT",
"engines": {
"node": ">= 0.8"
@@ -16145,6 +16541,7 @@
"version": "1.16.2",
"resolved": "https://registry.npmjs.org/serve-static/-/serve-static-1.16.2.tgz",
"integrity": "sha512-VqpjJZKadQB/PEbEwvFdO43Ax5dFBZ2UECszz8bQ7pi7wt//PWe1P6MN7eCnjsatYtBT6EuiClbjSWP2WrIoTw==",
+ "dev": true,
"license": "MIT",
"dependencies": {
"encodeurl": "~2.0.0",