occam-server 2.0.0 → 7.0.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (73) hide show
  1. package/.swcrc +5 -0
  2. package/README.md +40 -30
  3. package/lib/constants.js +26 -0
  4. package/lib/createProjectEntries.js +63 -0
  5. package/lib/index.js +75 -0
  6. package/lib/loadFile.js +18 -0
  7. package/lib/loadFiles.js +18 -0
  8. package/lib/loadProject.js +18 -0
  9. package/lib/loadProjects.js +18 -0
  10. package/lib/loadRelease.js +18 -0
  11. package/lib/loadReleases.js +18 -0
  12. package/lib/moveProjectEntries.js +77 -0
  13. package/lib/removeProjectEntries.js +68 -0
  14. package/lib/removeRelease.js +32 -0
  15. package/lib/renameProjectEntries.js +74 -0
  16. package/lib/saveFile.js +19 -0
  17. package/lib/utilities/fileSystem.js +255 -0
  18. package/lib/utilities/http.js +76 -0
  19. package/lib/utilities/name.js +16 -0
  20. package/lib/utilities/pathMap.js +58 -0
  21. package/license.txt +48 -0
  22. package/package.json +20 -22
  23. package/src/constants.js +5 -0
  24. package/src/createProjectEntries.js +71 -0
  25. package/src/index.js +16 -0
  26. package/src/loadFile.js +15 -0
  27. package/src/loadFiles.js +15 -0
  28. package/src/loadProject.js +15 -0
  29. package/src/loadProjects.js +14 -0
  30. package/src/loadRelease.js +14 -0
  31. package/src/loadReleases.js +13 -0
  32. package/src/moveProjectEntries.js +102 -0
  33. package/src/removeProjectEntries.js +79 -0
  34. package/src/removeRelease.js +35 -0
  35. package/src/renameProjectEntries.js +101 -0
  36. package/src/saveFile.js +14 -0
  37. package/src/utilities/fileSystem.js +364 -0
  38. package/src/utilities/http.js +71 -0
  39. package/src/utilities/name.js +7 -0
  40. package/src/utilities/pathMap.js +39 -0
  41. package/es6/handler/importProject.js +0 -23
  42. package/es6/handler/loadFile.js +0 -27
  43. package/es6/handler/loadFiles.js +0 -25
  44. package/es6/handler/loadProjects.js +0 -29
  45. package/es6/handler/moveProjectEntries.js +0 -24
  46. package/es6/handler/removeProjectEntries.js +0 -24
  47. package/es6/handler/saveFile.js +0 -23
  48. package/es6/handler/saveFiles.js +0 -23
  49. package/es6/handlers.js +0 -67
  50. package/es6/httpResponse.js +0 -46
  51. package/es6/main.js +0 -36
  52. package/es6/middleware/error.js +0 -11
  53. package/es6/paths.js +0 -7
  54. package/es6/routers.js +0 -47
  55. package/es6/uris.js +0 -25
  56. package/es6/utilities/query.js +0 -15
  57. package/index.js +0 -3
  58. package/lib/handler/importProject.js +0 -26
  59. package/lib/handler/loadFile.js +0 -29
  60. package/lib/handler/loadFiles.js +0 -28
  61. package/lib/handler/loadProjects.js +0 -31
  62. package/lib/handler/moveProjectEntries.js +0 -29
  63. package/lib/handler/removeProjectEntries.js +0 -29
  64. package/lib/handler/saveFile.js +0 -26
  65. package/lib/handler/saveFiles.js +0 -26
  66. package/lib/handlers.js +0 -81
  67. package/lib/httpResponse.js +0 -47
  68. package/lib/main.js +0 -41
  69. package/lib/middleware/error.js +0 -12
  70. package/lib/paths.js +0 -8
  71. package/lib/routers.js +0 -52
  72. package/lib/uris.js +0 -26
  73. package/lib/utilities/query.js +0 -16
@@ -0,0 +1,364 @@
1
+ "use strict";
2
+
3
+ import { arrayUtilities, pathUtilities, fileSystemUtilities } from "necessary";
4
+ import { File, Files, Entries, Project, Release, Projects, Releases, Directory, filePathUtilities } from "occam-model";
5
+
6
+ import { isNameHiddenName } from "../utilities/name";
7
+
8
+ const { first } = arrayUtilities,
9
+ { isFilePathRecognisedFilePath } = filePathUtilities,
10
+ { concatenatePaths, topmostDirectoryNameFromPath } = pathUtilities,
11
+ { readFile,
12
+ writeFile,
13
+ isEntryFile,
14
+ readDirectory,
15
+ isEntryDirectory,
16
+ checkEntryExists,
17
+ checkEntryExists: checkFileExists } = fileSystemUtilities;
18
+
19
+ export function loadFile(path, projectsDirectoryPath) {
20
+ let file = null;
21
+
22
+ try {
23
+ const topmostDirectoryName = topmostDirectoryNameFromPath(path);
24
+
25
+ if (topmostDirectoryName !== null) {
26
+ const absolutePath = concatenatePaths(projectsDirectoryPath, topmostDirectoryName),
27
+ entryDirectory = isEntryDirectory(absolutePath);
28
+
29
+ file = entryDirectory ?
30
+ fileFromProject(path, projectsDirectoryPath) :
31
+ fileFromRelease(path, projectsDirectoryPath);
32
+ }
33
+ } catch (error) {
34
+ ///
35
+ }
36
+
37
+ return file;
38
+ }
39
+
40
+ export function saveFile(file, projectsDirectoryPath) {
41
+ let success = false;
42
+
43
+ const filePath = file.getPath(),
44
+ absoluteFilePath = concatenatePaths(projectsDirectoryPath, filePath),
45
+ fileExists = checkFileExists(absoluteFilePath);
46
+
47
+ if (fileExists) {
48
+ const filePath = absoluteFilePath, ///
49
+ content = file.getContent();
50
+
51
+ try {
52
+ writeFile(filePath, content);
53
+ } catch (error) {
54
+ ///
55
+ }
56
+
57
+ success = true;
58
+ }
59
+
60
+ return success;
61
+ }
62
+
63
+ export function loadFiles(paths, projectsDirectoryPath) {
64
+ let files;
65
+
66
+ try {
67
+ files = Files.fromNothing();
68
+
69
+ const pathsLength = paths.length;
70
+
71
+ if (pathsLength > 0) {
72
+ const firstPath = first(paths),
73
+ path = firstPath, ///
74
+ topmostDirectoryName = topmostDirectoryNameFromPath(path);
75
+
76
+ if (topmostDirectoryName !== null) {
77
+ const absolutePath = concatenatePaths(projectsDirectoryPath, topmostDirectoryName),
78
+ entryExists = checkEntryExists(absolutePath);
79
+
80
+ if (entryExists) {
81
+ const entryDirectory = isEntryDirectory(absolutePath);
82
+
83
+ files = entryDirectory ?
84
+ filesFromProject(paths, projectsDirectoryPath) :
85
+ filesFromRelease(paths, projectsDirectoryPath);
86
+ }
87
+ }
88
+ }
89
+ } catch (error) {
90
+ files = null;
91
+ }
92
+
93
+ return files;
94
+ }
95
+
96
+ export function loadRelease(releaseName, projectsDirectoryPath) {
97
+ let release = null;
98
+
99
+ try {
100
+ const name = releaseName, ///
101
+ topmostFileName = releaseName, ///
102
+ absolutePath = concatenatePaths(projectsDirectoryPath, topmostFileName),
103
+ entryFile = isEntryFile(absolutePath);
104
+
105
+ if (entryFile) {
106
+ let json,
107
+ entries;
108
+
109
+ const content = readFile(absolutePath);
110
+
111
+ json = JSON.parse(content);
112
+
113
+ ({ entries } = json);
114
+
115
+ json = entries; ///
116
+
117
+ entries = Entries.fromJSON(json);
118
+
119
+ release = Release.fromNameAndEntries(name, entries);
120
+ }
121
+ } catch (error) {
122
+ ///
123
+ }
124
+
125
+ return release;
126
+ }
127
+
128
+ export function loadProject(projectName, projectsDirectoryPath, loadOnlyRecognisedFiles) {
129
+ let project = null;
130
+
131
+ try {
132
+ const name = projectName, ///
133
+ topmostDirectoryName = projectName, ///
134
+ entries = loadEntries(topmostDirectoryName, projectsDirectoryPath, loadOnlyRecognisedFiles);
135
+
136
+ project = Project.fromNameAndEntries(name, entries);
137
+ } catch (error) {
138
+ ///
139
+ }
140
+
141
+ return project;
142
+ }
143
+
144
+ export function loadReleases(projectsDirectoryPath) {
145
+ let releases;
146
+
147
+ try {
148
+ releases = Releases.fromNothing();
149
+
150
+ const topmostFileNames = topmostFileNamesFromProjectsDirectoryPath(projectsDirectoryPath),
151
+ releaseNames = topmostFileNames; ///
152
+
153
+ releaseNames.forEach((releaseName) => {
154
+ const release = loadRelease(releaseName, projectsDirectoryPath);
155
+
156
+ if (release !== null) {
157
+ releases.addRelease(release);
158
+ }
159
+ });
160
+ } catch (error) {
161
+ releases = null;
162
+ }
163
+
164
+ return releases;
165
+ }
166
+
167
+ export function loadProjects(projectsDirectoryPath, loadOnlyRecognisedFiles) {
168
+ let projects;
169
+
170
+ try {
171
+ projects = Projects.fromNothing();
172
+
173
+ const topmostDirectoryNames = topmostDirectoryNamesFromProjectsDirectoryPath(projectsDirectoryPath),
174
+ projectNames = topmostDirectoryNames; ///
175
+
176
+ projectNames.forEach((projectName) => {
177
+ const project = loadProject(projectName, projectsDirectoryPath, loadOnlyRecognisedFiles);
178
+
179
+ if (project !== null) {
180
+ projects.addProject(project);
181
+ }
182
+ });
183
+ } catch (error) {
184
+ projects = null;
185
+ }
186
+
187
+ return projects;
188
+ }
189
+
190
+ export default {
191
+ loadFile,
192
+ saveFile,
193
+ loadFiles,
194
+ loadRelease,
195
+ loadProject,
196
+ loadReleases,
197
+ loadProjects
198
+ };
199
+
200
+ function loadEntries(topmostDirectoryName, projectsDirectoryPath, loadOnlyRecognisedFiles) {
201
+ const entries = Entries.fromNothing(),
202
+ relativeDirectoryPath = topmostDirectoryName; ///
203
+
204
+ entriesFromRelativeDirectoryPath(entries, relativeDirectoryPath, projectsDirectoryPath, loadOnlyRecognisedFiles);
205
+
206
+ return entries;
207
+ }
208
+
209
+ function loadDirectory(path, projectsDirectoryPath) {
210
+ const absolutePath = concatenatePaths(projectsDirectoryPath, path),
211
+ entryDirectory = isEntryDirectory(absolutePath),
212
+ directory = entryDirectory ?
213
+ Directory.fromPath(path) :
214
+ null;
215
+
216
+ return directory;
217
+ }
218
+
219
+ function fileFromProject(path, projectsDirectoryPath) {
220
+ let file = null;
221
+
222
+ const absolutePath = concatenatePaths(projectsDirectoryPath, path),
223
+ entryFile = isEntryFile(absolutePath);
224
+
225
+ if (entryFile) {
226
+ const released = false,
227
+ content = readFile(absolutePath);
228
+
229
+ file = File.fromPathContentAndReleased(path, content, released);
230
+ }
231
+
232
+ return file;
233
+ }
234
+
235
+ function fileFromRelease(path, projectsDirectoryPath) {
236
+ const topmostDirectoryName = topmostDirectoryNameFromPath(path),
237
+ topmostFileName = topmostDirectoryName, ///
238
+ filePath = path, ///
239
+ release = loadRelease(topmostFileName, projectsDirectoryPath),
240
+ file = release.findFile(filePath);
241
+
242
+ return file;
243
+ }
244
+
245
+ function filesFromProject(paths, projectsDirectoryPath) {
246
+ const files = Files.fromNothing();
247
+
248
+ paths.forEach((path) => {
249
+ const file = fileFromProject(path, projectsDirectoryPath);
250
+
251
+ files.addFile(file);
252
+ });
253
+
254
+ return files;
255
+ }
256
+
257
+ function filesFromRelease(paths, projectsDirectoryPath) {
258
+ const files = Files.fromNothing(),
259
+ pathsLength = paths.length;
260
+
261
+ if (pathsLength > 0) {
262
+ const firstPath = first(paths),
263
+ path = firstPath, ///
264
+ topmostDirectoryName = topmostDirectoryNameFromPath(path),
265
+ topmostFileName = topmostDirectoryName, ///
266
+ release = loadRelease(topmostFileName, projectsDirectoryPath);
267
+
268
+ paths.forEach((path) => {
269
+ const filePath = path, ///
270
+ file = release.findFile(filePath);
271
+
272
+ files.addFile(file);
273
+ });
274
+ }
275
+
276
+ return files;
277
+ }
278
+
279
+ function entriesFromRelativeDirectoryPath(entries, relativeDirectoryPath, projectsDirectoryPath, loadOnlyRecognisedFiles) {
280
+ const absoluteDirectoryPath = concatenatePaths(projectsDirectoryPath, relativeDirectoryPath),
281
+ subEntryNames = readDirectory(absoluteDirectoryPath);
282
+
283
+ subEntryNames.forEach((subEntryName) => {
284
+ const subEntryNameHiddenName = isNameHiddenName(subEntryName),
285
+ loadUnrecognisedFilesAndDirectories = !loadOnlyRecognisedFiles;
286
+
287
+ if (!subEntryNameHiddenName) {
288
+ const path = concatenatePaths(relativeDirectoryPath, subEntryName),
289
+ directory = loadDirectory(path, projectsDirectoryPath);
290
+
291
+ if (directory !== null) {
292
+ const directoryPath = path; ///
293
+
294
+ if (loadUnrecognisedFilesAndDirectories) {
295
+ entries.addDirectory(directory);
296
+ }
297
+
298
+ entriesFromRelativeDirectoryPath(entries, directoryPath, projectsDirectoryPath, loadOnlyRecognisedFiles); ///
299
+ } else {
300
+ const file = loadFile(path, projectsDirectoryPath);
301
+
302
+ if (file !== null) {
303
+ const filePath = file.getPath(),
304
+ filePathRecognisedFilePath = isFilePathRecognisedFilePath(filePath),
305
+ fileRecognisedFile = filePathRecognisedFilePath; ///
306
+
307
+ if (fileRecognisedFile || loadUnrecognisedFilesAndDirectories) {
308
+ entries.addFile(file);
309
+ }
310
+ }
311
+ }
312
+ }
313
+ });
314
+ }
315
+
316
+ function topmostFileNamesFromProjectsDirectoryPath(projectsDirectoryPath) {
317
+ let topmostFileNames;
318
+
319
+ const subEntryNames = readDirectory(projectsDirectoryPath);
320
+
321
+ topmostFileNames = subEntryNames.reduce((topmostFileNames, subEntryName) => {
322
+ const absoluteSubEntryPath = concatenatePaths(projectsDirectoryPath, subEntryName),
323
+ subEntryNameHiddenName = isNameHiddenName(subEntryName);
324
+
325
+ if (!subEntryNameHiddenName) {
326
+ const subEntryFile = isEntryFile(absoluteSubEntryPath);
327
+
328
+ if (subEntryFile) {
329
+ const topmostFileName = subEntryName; ///
330
+
331
+ topmostFileNames.push(topmostFileName)
332
+ }
333
+ }
334
+
335
+ return topmostFileNames;
336
+ }, []);
337
+
338
+ return topmostFileNames;
339
+ }
340
+
341
+ function topmostDirectoryNamesFromProjectsDirectoryPath(projectsDirectoryPath) {
342
+ let topmostDirectoryNames;
343
+
344
+ const subEntryNames = readDirectory(projectsDirectoryPath);
345
+
346
+ topmostDirectoryNames = subEntryNames.reduce((topmostDirectoryNames, subEntryName) => {
347
+ const absoluteSubEntryPath = concatenatePaths(projectsDirectoryPath, subEntryName),
348
+ subEntryNameHiddenName = isNameHiddenName(subEntryName);
349
+
350
+ if (!subEntryNameHiddenName) {
351
+ const subEntryDirectory = isEntryDirectory(absoluteSubEntryPath);
352
+
353
+ if (subEntryDirectory) {
354
+ const topmostDirectoryName = subEntryName; ///
355
+
356
+ topmostDirectoryNames.push(topmostDirectoryName)
357
+ }
358
+ }
359
+
360
+ return topmostDirectoryNames;
361
+ }, []);
362
+
363
+ return topmostDirectoryNames;
364
+ }
@@ -0,0 +1,71 @@
1
+ "use strict";
2
+
3
+ import { Readable } from "stream";
4
+
5
+ import { methods, headers, contentTypes, statusCodes, requestUtilities } from "necessary";
6
+
7
+ import { END, DATA, EMPTY_STRING } from "../constants";
8
+
9
+ const { POST_METHOD } = methods,
10
+ { createRequest } = requestUtilities,
11
+ { OK_200_STATUS_CODE } = statusCodes,
12
+ { ACCEPT_HEADER, CONTENT_TYPE_HEADER } = headers,
13
+ { APPLICATION_JSON_CHARSET_UTF_8_CONTENT_TYPE } = contentTypes;
14
+
15
+ export function post(host, uri, query, json, callback) {
16
+ const content = JSON.stringify(json), ///
17
+ method = POST_METHOD,
18
+ headers = {
19
+ [ACCEPT_HEADER]: APPLICATION_JSON_CHARSET_UTF_8_CONTENT_TYPE,
20
+ [CONTENT_TYPE_HEADER]: APPLICATION_JSON_CHARSET_UTF_8_CONTENT_TYPE
21
+ };
22
+
23
+ const request = createRequest(host, uri, query, method, headers, (error, response) => {
24
+ if (response === null) {
25
+ error = true;
26
+ } else {
27
+ const { statusCode } = response;
28
+
29
+ if (statusCode !== OK_200_STATUS_CODE) {
30
+ error = true;
31
+ }
32
+ }
33
+
34
+ if (error) {
35
+ const json = null;
36
+
37
+ callback(json);
38
+
39
+ return;
40
+ }
41
+
42
+ contentFromResponse(response, (content) => {
43
+ let json = null;
44
+
45
+ try {
46
+ json = JSON.parse(content);
47
+ } catch (error) {} ///
48
+
49
+ callback(json);
50
+ });
51
+ }),
52
+ readable = Readable.from(content);
53
+
54
+ readable.pipe(request);
55
+ }
56
+
57
+ export default {
58
+ post
59
+ };
60
+
61
+ function contentFromResponse(response, callback) {
62
+ let content = EMPTY_STRING;
63
+
64
+ response.on(DATA, (data) => {
65
+ content += data;
66
+ });
67
+
68
+ response.on(END, () => {
69
+ callback(content);
70
+ });
71
+ }
@@ -0,0 +1,7 @@
1
+ "use strict";
2
+
3
+ export function isNameHiddenName(name) {
4
+ const nameHiddenName = /^\..+/.test(name);
5
+
6
+ return nameHiddenName;
7
+ }
@@ -0,0 +1,39 @@
1
+ "use strict";
2
+
3
+ export function nullifyEntryPaths(pathMap) {
4
+ const sourceEntryPath = null,
5
+ targetEntryPath = null;
6
+
7
+ Object.assign(pathMap, {
8
+ sourceEntryPath,
9
+ targetEntryPath
10
+ });
11
+ }
12
+
13
+ export function nullifySourceEntryPath(pathMap) {
14
+ const sourceEntryPath = null;
15
+
16
+ Object.assign(pathMap, {
17
+ sourceEntryPath
18
+ });
19
+ }
20
+
21
+ export function nullifyTargetEntryPath(pathMap) {
22
+ const targetEntryPath = null;
23
+
24
+ Object.assign(pathMap, {
25
+ targetEntryPath
26
+ });
27
+ }
28
+
29
+ export function nullifySourceEntryPaths(pathMaps) {
30
+ pathMaps.forEach((pathMap) => {
31
+ nullifySourceEntryPath(pathMap);
32
+ });
33
+ }
34
+
35
+ export function nullifyTargetEntryPaths(pathMaps) {
36
+ pathMaps.forEach((pathMap) => {
37
+ nullifyTargetEntryPath(pathMap);
38
+ });
39
+ }
@@ -1,23 +0,0 @@
1
- 'use strict';
2
-
3
- const filesystem = require('occam-file-system'); ///
4
-
5
- const httpResponse = require('../httpResponse');
6
-
7
- const { importProject } = filesystem;
8
-
9
- function importProjectHandler(request, response, next) {
10
- const { query, } = request,
11
- { url } = query;
12
-
13
- importProject(url, function(project) {
14
- const projectJSON = project.toJSON(),
15
- responseJSON = projectJSON; ///
16
-
17
- httpResponse.json(response, responseJSON);
18
-
19
- next();
20
- });
21
- }
22
-
23
- module.exports = importProjectHandler;
@@ -1,27 +0,0 @@
1
- 'use strict';
2
-
3
- const filesystem = require('occam-file-system'); ///
4
-
5
- const httpResponse = require('../httpResponse');
6
-
7
- const { loadFile } = filesystem;
8
-
9
- function loadFileHandler(request, response, next) {
10
- const { query, body } = request,
11
- { filePath } = body,
12
- { projectsDirectoryPath } = query,
13
- path = filePath; ///
14
-
15
- loadFile(projectsDirectoryPath, path, function(file) {
16
- const fileJSON = (file !== null) ? ///
17
- file.toJSON() :
18
- null,
19
- responseJSON = fileJSON; ///
20
-
21
- httpResponse.json(response, responseJSON);
22
-
23
- next();
24
- });
25
- }
26
-
27
- module.exports = loadFileHandler;
@@ -1,25 +0,0 @@
1
- 'use strict';
2
-
3
- const filesystem = require('occam-file-system'); ///
4
-
5
- const httpResponse = require('../httpResponse');
6
-
7
- const { loadFiles } = filesystem;
8
-
9
- function loadFilesHandler(request, response, next) {
10
- const { query, body } = request,
11
- { filePaths } = body,
12
- { projectsDirectoryPath } = query,
13
- paths = filePaths; ///
14
-
15
- loadFiles(projectsDirectoryPath, paths, function(files) {
16
- const filesJSON = files.toJSON(),
17
- responseJSON = filesJSON; ///
18
-
19
- httpResponse.json(response, responseJSON);
20
-
21
- next();
22
- });
23
- }
24
-
25
- module.exports = loadFilesHandler;
@@ -1,29 +0,0 @@
1
- 'use strict';
2
-
3
- const filesystem = require('occam-file-system'); ///
4
-
5
- const httpResponse = require('../httpResponse'),
6
- queryUtilities = require('../utilities/query');
7
-
8
- const { toBoolean } = queryUtilities,
9
- { loadProjects } = filesystem;
10
-
11
- function loadProjectsHandler(request, response, next) {
12
- const { query } = request,
13
- { projectsDirectoryPath } = query;
14
-
15
- let { doNotLoadHiddenFilesAndDirectories } = query;
16
-
17
- doNotLoadHiddenFilesAndDirectories = toBoolean(doNotLoadHiddenFilesAndDirectories); ///
18
-
19
- loadProjects(projectsDirectoryPath, doNotLoadHiddenFilesAndDirectories, function(projects) {
20
- const projectsJSON = projects.toJSON(),
21
- responseJSON = projectsJSON; ///
22
-
23
- httpResponse.json(response, responseJSON);
24
-
25
- next();
26
- });
27
- }
28
-
29
- module.exports = loadProjectsHandler;
@@ -1,24 +0,0 @@
1
- 'use strict';
2
-
3
- const filesystem = require('occam-file-system'); ///
4
-
5
- const httpResponse = require('../httpResponse');
6
-
7
- const { moveProjectEntries } = filesystem;
8
-
9
- function moveProjectEntriesHandler(request, response, next) {
10
- const { query, body } = request,
11
- { pathMaps } = body,
12
- { projectsDirectoryPath } = query;
13
-
14
- moveProjectEntries(projectsDirectoryPath, pathMaps, function(targetPaths) {
15
- const targetPathsJSON = targetPaths, ///
16
- responseJSON = targetPathsJSON; ///
17
-
18
- httpResponse.json(response, responseJSON);
19
-
20
- next();
21
- });
22
- }
23
-
24
- module.exports = moveProjectEntriesHandler;
@@ -1,24 +0,0 @@
1
- 'use strict';
2
-
3
- const filesystem = require('occam-file-system'); ///
4
-
5
- const httpResponse = require('../httpResponse');
6
-
7
- const { removeProjectEntries } = filesystem;
8
-
9
- function removeProjectEntriesHandler(request, response, next) {
10
- const { query, body } = request,
11
- { pathMaps } = body,
12
- { projectsDirectoryPath } = query;
13
-
14
- removeProjectEntries(projectsDirectoryPath, pathMaps, function(targetPaths) {
15
- const targetPathsJSON = targetPaths, ///
16
- responseJSON = targetPathsJSON; ///
17
-
18
- httpResponse.json(response, responseJSON);
19
-
20
- next();
21
- });
22
- }
23
-
24
- module.exports = removeProjectEntriesHandler;
@@ -1,23 +0,0 @@
1
- 'use strict';
2
-
3
- const filesystem = require('occam-file-system'); ///
4
-
5
- const httpResponse = require('../httpResponse');
6
-
7
- const { saveFile } = filesystem;
8
-
9
- function saveFileHandler(request, response, next) {
10
- const { query, body } = request,
11
- { projectsDirectoryPath } = query,
12
- json = body; ///
13
-
14
- saveFile(projectsDirectoryPath, json, function(success) {
15
- const responseJSON = {};
16
-
17
- httpResponse.json(response, responseJSON);
18
-
19
- next();
20
- });
21
- }
22
-
23
- module.exports = saveFileHandler;
@@ -1,23 +0,0 @@
1
- 'use strict';
2
-
3
- const filesystem = require('occam-file-system'); ///
4
-
5
- const httpResponse = require('../httpResponse');
6
-
7
- const { saveFiles } = filesystem;
8
-
9
- function saveFilesHandler(request, response, next) {
10
- const { query, body } = request,
11
- { projectsDirectoryPath } = query,
12
- json = body; ///
13
-
14
- saveFiles(projectsDirectoryPath, json, function(success) {
15
- const responseJSON = {};
16
-
17
- httpResponse.json(response, responseJSON);
18
-
19
- next();
20
- });
21
- }
22
-
23
- module.exports = saveFilesHandler;