MCPcopy
hub / github.com/chartbrew/chartbrew / createTeam

Method createTeam

server/controllers/TeamController.js:28–62  ·  view source on GitHub ↗
(data, userId)

Source from the content-addressed store, hash-verified

26
27 // create a new team
28 async createTeam(data, userId) {
29 const team = await db.Team.create({ "name": data.name });
30 await db.TeamRole.create({
31 team_id: team.id,
32 user_id: userId,
33 role: "teamOwner",
34 });
35
36 // create an empty ghost project for the team
37 await db.Project.create({
38 team_id: team.id,
39 name: "Ghost Project",
40 brewName: `ghost-project-${nanoid(8)}`,
41 dashboardTitle: "Ghost Project",
42 ghost: true,
43 public: false,
44 });
45
46 // create a default dashboard for the team
47 await db.Project.create({
48 team_id: team.id,
49 name: "First Dashboard",
50 brewName: `first-dashboard-${nanoid(8)}`,
51 description: `First dashboard for ${team.name}`,
52 public: false,
53 });
54
55 // get the team with the TeamRoles
56 const teamWithRoles = await db.Team.findOne({
57 where: { id: team.id },
58 include: [{ model: db.TeamRole }],
59 });
60
61 return teamWithRoles;
62 }
63
64 async deleteTeam(teamId, userId) {
65 // first check if the user owns other teams

Callers 1

TeamRoute.jsFile · 0.80

Calls 1

createMethod · 0.45

Tested by

no test coverage detected