diff options
author | 2021-08-16 18:10:23 +0200 | |
---|---|---|
committer | 2021-08-16 21:40:23 +0530 | |
commit | 26a9dba22236bc22a7612107630282cfe02d20e0 (patch) | |
tree | 25af338b5a4b080a3bd2c60c500a34cafdff3581 /src/internal-server/app/Controllers/Http/WorkspaceController.js | |
parent | chore: replace moment.js with day.js (#1804) (diff) | |
download | ferdium-app-26a9dba22236bc22a7612107630282cfe02d20e0.tar.gz ferdium-app-26a9dba22236bc22a7612107630282cfe02d20e0.tar.zst ferdium-app-26a9dba22236bc22a7612107630282cfe02d20e0.zip |
chore: update outdated node_modules (#1807)
- upgrade 'uuid', '@types/uuid', 'macos-version', 'normalize-url' and 'os-name' dependencies to latest
- updated 'macos-version' imports to named imports
Diffstat (limited to 'src/internal-server/app/Controllers/Http/WorkspaceController.js')
-rw-r--r-- | src/internal-server/app/Controllers/Http/WorkspaceController.js | 57 |
1 files changed, 24 insertions, 33 deletions
diff --git a/src/internal-server/app/Controllers/Http/WorkspaceController.js b/src/internal-server/app/Controllers/Http/WorkspaceController.js index 4189fbcdd..f1a5ddf2b 100644 --- a/src/internal-server/app/Controllers/Http/WorkspaceController.js +++ b/src/internal-server/app/Controllers/Http/WorkspaceController.js | |||
@@ -1,16 +1,11 @@ | |||
1 | const Workspace = use('App/Models/Workspace'); | 1 | const Workspace = use('App/Models/Workspace'); |
2 | const { | 2 | const { validateAll } = use('Validator'); |
3 | validateAll, | ||
4 | } = use('Validator'); | ||
5 | 3 | ||
6 | const uuid = require('uuid/v4'); | 4 | const { v4: uuid } = require('uuid'); |
7 | 5 | ||
8 | class WorkspaceController { | 6 | class WorkspaceController { |
9 | // Create a new workspace for user | 7 | // Create a new workspace for user |
10 | async create({ | 8 | async create({ request, response }) { |
11 | request, | ||
12 | response, | ||
13 | }) { | ||
14 | // Validate user input | 9 | // Validate user input |
15 | const validation = await validateAll(request.all(), { | 10 | const validation = await validateAll(request.all(), { |
16 | name: 'required', | 11 | name: 'required', |
@@ -29,7 +24,10 @@ class WorkspaceController { | |||
29 | let workspaceId; | 24 | let workspaceId; |
30 | do { | 25 | do { |
31 | workspaceId = uuid(); | 26 | workspaceId = uuid(); |
32 | } while ((await Workspace.query().where('workspaceId', workspaceId).fetch()).rows.length > 0); // eslint-disable-line no-await-in-loop | 27 | } while ( |
28 | (await Workspace.query().where('workspaceId', workspaceId).fetch()).rows | ||
29 | .length > 0 | ||
30 | ); // eslint-disable-line no-await-in-loop | ||
33 | 31 | ||
34 | const order = (await Workspace.all()).rows.length; | 32 | const order = (await Workspace.all()).rows.length; |
35 | 33 | ||
@@ -50,11 +48,7 @@ class WorkspaceController { | |||
50 | }); | 48 | }); |
51 | } | 49 | } |
52 | 50 | ||
53 | async edit({ | 51 | async edit({ request, response, params }) { |
54 | request, | ||
55 | response, | ||
56 | params, | ||
57 | }) { | ||
58 | // Validate user input | 52 | // Validate user input |
59 | const validation = await validateAll(request.all(), { | 53 | const validation = await validateAll(request.all(), { |
60 | name: 'required', | 54 | name: 'required', |
@@ -69,20 +63,19 @@ class WorkspaceController { | |||
69 | } | 63 | } |
70 | 64 | ||
71 | const data = request.all(); | 65 | const data = request.all(); |
72 | const { | 66 | const { id } = params; |
73 | id, | ||
74 | } = params; | ||
75 | 67 | ||
76 | // Update data in database | 68 | // Update data in database |
77 | await (Workspace.query() | 69 | await Workspace.query() |
78 | .where('workspaceId', id)).update({ | 70 | .where('workspaceId', id) |
79 | name: data.name, | 71 | .update({ |
80 | services: JSON.stringify(data.services), | 72 | name: data.name, |
81 | }); | 73 | services: JSON.stringify(data.services), |
74 | }); | ||
82 | 75 | ||
83 | // Get updated row | 76 | // Get updated row |
84 | const workspace = (await Workspace.query() | 77 | const workspace = (await Workspace.query().where('workspaceId', id).fetch()) |
85 | .where('workspaceId', id).fetch()).rows[0]; | 78 | .rows[0]; |
86 | 79 | ||
87 | return response.send({ | 80 | return response.send({ |
88 | id: workspace.workspaceId, | 81 | id: workspace.workspaceId, |
@@ -111,13 +104,10 @@ class WorkspaceController { | |||
111 | }); | 104 | }); |
112 | } | 105 | } |
113 | 106 | ||
114 | const { | 107 | const { id } = params; |
115 | id, | ||
116 | } = params; | ||
117 | 108 | ||
118 | // Update data in database | 109 | // Update data in database |
119 | await (Workspace.query() | 110 | await Workspace.query().where('workspaceId', id).delete(); |
120 | .where('workspaceId', id)).delete(); | ||
121 | 111 | ||
122 | return response.send({ | 112 | return response.send({ |
123 | message: 'Successfully deleted workspace', | 113 | message: 'Successfully deleted workspace', |
@@ -125,9 +115,7 @@ class WorkspaceController { | |||
125 | } | 115 | } |
126 | 116 | ||
127 | // List all workspaces a user has created | 117 | // List all workspaces a user has created |
128 | async list({ | 118 | async list({ response }) { |
129 | response, | ||
130 | }) { | ||
131 | const workspaces = (await Workspace.all()).rows; | 119 | const workspaces = (await Workspace.all()).rows; |
132 | // Convert to array with all data Franz wants | 120 | // Convert to array with all data Franz wants |
133 | let workspacesArray = []; | 121 | let workspacesArray = []; |
@@ -136,7 +124,10 @@ class WorkspaceController { | |||
136 | id: workspace.workspaceId, | 124 | id: workspace.workspaceId, |
137 | name: workspace.name, | 125 | name: workspace.name, |
138 | order: workspace.order, | 126 | order: workspace.order, |
139 | services: typeof workspace.services === 'string' ? JSON.parse(workspace.services) : workspace.services, | 127 | services: |
128 | typeof workspace.services === 'string' | ||
129 | ? JSON.parse(workspace.services) | ||
130 | : workspace.services, | ||
140 | userId: 1, | 131 | userId: 1, |
141 | })); | 132 | })); |
142 | } | 133 | } |