Skip to content

Commit 86a2512

Browse files
committed
refactor(backend): separate team settings into dedicated settings group
Move team-related settings from global settings group to new team settings group. Changes setting keys from global.team_* to team.* format for better organization. - Create team.ts settings file with 4 team settings - Remove team settings from global.ts - Update references in teamService.ts and createTeam.ts
1 parent 0d540a0 commit 86a2512

File tree

4 files changed

+56
-43
lines changed

4 files changed

+56
-43
lines changed

services/backend/src/global-settings/global.ts

Lines changed: 0 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -63,24 +63,6 @@ export const globalSettings: GlobalSettingsModule = {
6363
encrypted: false,
6464
required: false
6565
},
66-
{
67-
key: 'global.team_member_limit',
68-
name: 'Team Member Limit',
69-
defaultValue: 3,
70-
type: 'number',
71-
description: 'Maximum number of members allowed in non-default teams. Default teams are always limited to 1 member (the owner).',
72-
encrypted: false,
73-
required: false
74-
},
75-
{
76-
key: 'global.team_creation_limit',
77-
name: 'Team Creation Limit',
78-
defaultValue: 3,
79-
type: 'number',
80-
description: 'Maximum number of teams a user can create, including both default and custom teams.',
81-
encrypted: false,
82-
required: false
83-
},
8466
{
8567
key: 'global.send_welcome_email',
8668
name: 'Send Welcome Email',
@@ -98,24 +80,6 @@ export const globalSettings: GlobalSettingsModule = {
9880
description: 'Display onboarding walkthrough for users who have not completed or cancelled it.',
9981
encrypted: false,
10082
required: false
101-
},
102-
{
103-
key: 'global.default_non_http_mcp_limit',
104-
name: 'Default Non-HTTP MCP Limit',
105-
defaultValue: 1,
106-
type: 'number',
107-
description: 'Maximum number of non-HTTP (stdio) MCP servers per team. Applied when a new team is created. HTTP and SSE servers are not affected.',
108-
encrypted: false,
109-
required: false
110-
},
111-
{
112-
key: 'global.default_mcp_server_limit',
113-
name: 'Default MCP Server Limit',
114-
defaultValue: 5,
115-
type: 'number',
116-
description: 'Maximum total number of MCP server installations per team. Applied when a new team is created. Includes all transport types (HTTP, SSE, stdio).',
117-
encrypted: false,
118-
required: false
11983
}
12084
]
12185
};
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
import type { GlobalSettingsModule } from './types';
2+
3+
export const teamSettings: GlobalSettingsModule = {
4+
group: {
5+
id: 'team',
6+
name: 'Team Settings',
7+
description: 'Team management and limit configuration',
8+
icon: 'users',
9+
sort_order: 2
10+
},
11+
settings: [
12+
{
13+
key: 'team.member_limit',
14+
name: 'Team Member Limit',
15+
defaultValue: 3,
16+
type: 'number',
17+
description: 'Maximum number of members allowed in non-default teams. Default teams are always limited to 1 member (the owner).',
18+
encrypted: false,
19+
required: false
20+
},
21+
{
22+
key: 'team.creation_limit',
23+
name: 'Team Creation Limit',
24+
defaultValue: 3,
25+
type: 'number',
26+
description: 'Maximum number of teams a user can create, including both default and custom teams.',
27+
encrypted: false,
28+
required: false
29+
},
30+
{
31+
key: 'team.default_non_http_mcp_limit',
32+
name: 'Default Non-HTTP MCP Limit',
33+
defaultValue: 1,
34+
type: 'number',
35+
description: 'Maximum number of non-HTTP (stdio) MCP servers per team. Applied when a new team is created. HTTP and SSE servers are not affected.',
36+
encrypted: false,
37+
required: false
38+
},
39+
{
40+
key: 'team.default_mcp_server_limit',
41+
name: 'Default MCP Server Limit',
42+
defaultValue: 5,
43+
type: 'number',
44+
description: 'Maximum total number of MCP server installations per team. Applied when a new team is created. Includes all transport types (HTTP, SSE, stdio).',
45+
encrypted: false,
46+
required: false
47+
}
48+
]
49+
};

services/backend/src/routes/teams/createTeam.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ export default async function createTeamRoute(server: FastifyInstance) {
7878
if (!canCreate) {
7979
// Get the current team limit for a proper error message
8080
const { GlobalSettings } = await import('../../global-settings/helpers');
81-
const teamLimit = await GlobalSettings.getNumber('global.team_creation_limit', 3);
81+
const teamLimit = await GlobalSettings.getNumber('team.creation_limit', 3);
8282
const errorResponse: ErrorResponse = {
8383
success: false,
8484
error: `You have reached the maximum limit of ${teamLimit} teams`

services/backend/src/services/teamService.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -134,11 +134,11 @@ export class TeamService {
134134
// Get the default MCP limits from global settings if not provided
135135
const nonHttpMcpLimit = data.non_http_mcp_limit !== undefined
136136
? data.non_http_mcp_limit
137-
: await GlobalSettings.getNumber('global.default_non_http_mcp_limit', 1);
137+
: await GlobalSettings.getNumber('team.default_non_http_mcp_limit', 1);
138138

139139
const mcpServerLimit = data.mcp_server_limit !== undefined
140140
? data.mcp_server_limit
141-
: await GlobalSettings.getNumber('global.default_mcp_server_limit', 5);
141+
: await GlobalSettings.getNumber('team.default_mcp_server_limit', 5);
142142

143143
// Create the team
144144
const teamData = {
@@ -253,7 +253,7 @@ export class TeamService {
253253
*/
254254
static async canUserCreateTeam(userId: string): Promise<boolean> {
255255
const teamCount = await this.getUserTeamCount(userId);
256-
const teamLimit = await GlobalSettings.getNumber('global.team_creation_limit', 3);
256+
const teamLimit = await GlobalSettings.getNumber('team.creation_limit', 3);
257257
return teamCount < teamLimit;
258258
}
259259

@@ -722,8 +722,8 @@ export class TeamService {
722722
}
723723

724724
// Get team member limit from global settings
725-
const memberLimit = await GlobalSettings.getNumber('global.team_member_limit', 3);
726-
725+
const memberLimit = await GlobalSettings.getNumber('team.member_limit', 3);
726+
727727
// Check if team has less than the configured limit
728728
const memberCount = await this.getTeamMemberCount(teamId);
729729
return memberCount < memberLimit;
@@ -829,7 +829,7 @@ export class TeamService {
829829
throw new Error('Cannot add members to default teams');
830830
} else {
831831
// Get the actual limit for the error message
832-
const memberLimit = await GlobalSettings.getNumber('global.team_member_limit', 3);
832+
const memberLimit = await GlobalSettings.getNumber('team.member_limit', 3);
833833
throw new Error(`Team has reached maximum capacity (${memberLimit} members)`);
834834
}
835835
}

0 commit comments

Comments
 (0)