Commit 917cbd16ccfd672a815d953a82f467230a2746b8

Authored by Ali B
1 parent 466f0c04

The mock API is complete and endpoints now work properly with mock data. Created…

… a README file in restApi folder for instructions on how to start the server locally. Also created a Deployment diagram for current version of the server and how we plan to do it in the future
restApi/.idea/workspace.xml
... ... @@ -2,76 +2,11 @@
2 2 <project version="4">
3 3 <component name="ChangeListManager">
4 4 <list default="true" id="8a337026-05ab-47b0-872d-ab1e8037e9a0" name="Default" comment="">
5   - <change afterPath="$PROJECT_DIR$/.idea/misc.xml" afterDir="false" />
6   - <change beforePath="$PROJECT_DIR$/../Risiko/.idea/modules.xml" beforeDir="false" afterPath="$PROJECT_DIR$/../Risiko/.idea/modules.xml" afterDir="false" />
  5 + <change afterPath="$PROJECT_DIR$/api/modules/activity.js" afterDir="false" />
  6 + <change afterPath="$PROJECT_DIR$/api/modules/evaluation.js" afterDir="false" />
7 7 <change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
8   - <change beforePath="$PROJECT_DIR$/api/controllers/evaluationController.js" beforeDir="false" afterPath="$PROJECT_DIR$/api/models/incident.js" afterDir="false" />
9   - <change beforePath="$PROJECT_DIR$/api/models/evaluationModel.js" beforeDir="false" afterPath="$PROJECT_DIR$/api/routes/routes.js" afterDir="false" />
10   - <change beforePath="$PROJECT_DIR$/api/routes/evaluationRoutes.js" beforeDir="false" />
11   - <change beforePath="$PROJECT_DIR$/node_modules/body-parser/HISTORY.md" beforeDir="false" afterPath="$PROJECT_DIR$/node_modules/body-parser/HISTORY.md" afterDir="false" />
12   - <change beforePath="$PROJECT_DIR$/node_modules/body-parser/LICENSE" beforeDir="false" afterPath="$PROJECT_DIR$/node_modules/body-parser/LICENSE" afterDir="false" />
13   - <change beforePath="$PROJECT_DIR$/node_modules/body-parser/README.md" beforeDir="false" afterPath="$PROJECT_DIR$/node_modules/body-parser/README.md" afterDir="false" />
14   - <change beforePath="$PROJECT_DIR$/node_modules/body-parser/index.js" beforeDir="false" afterPath="$PROJECT_DIR$/node_modules/body-parser/index.js" afterDir="false" />
15   - <change beforePath="$PROJECT_DIR$/node_modules/body-parser/lib/read.js" beforeDir="false" afterPath="$PROJECT_DIR$/node_modules/body-parser/lib/read.js" afterDir="false" />
16   - <change beforePath="$PROJECT_DIR$/node_modules/body-parser/lib/types/json.js" beforeDir="false" afterPath="$PROJECT_DIR$/node_modules/body-parser/lib/types/json.js" afterDir="false" />
17   - <change beforePath="$PROJECT_DIR$/node_modules/body-parser/lib/types/raw.js" beforeDir="false" afterPath="$PROJECT_DIR$/node_modules/body-parser/lib/types/raw.js" afterDir="false" />
18   - <change beforePath="$PROJECT_DIR$/node_modules/body-parser/lib/types/text.js" beforeDir="false" afterPath="$PROJECT_DIR$/node_modules/body-parser/lib/types/text.js" afterDir="false" />
19   - <change beforePath="$PROJECT_DIR$/node_modules/body-parser/lib/types/urlencoded.js" beforeDir="false" afterPath="$PROJECT_DIR$/node_modules/body-parser/lib/types/urlencoded.js" afterDir="false" />
20   - <change beforePath="$PROJECT_DIR$/node_modules/body-parser/package.json" beforeDir="false" afterPath="$PROJECT_DIR$/node_modules/body-parser/package.json" afterDir="false" />
21   - <change beforePath="$PROJECT_DIR$/node_modules/iconv-lite/.npmignore" beforeDir="false" />
22   - <change beforePath="$PROJECT_DIR$/node_modules/iconv-lite/.travis.yml" beforeDir="false" afterPath="$PROJECT_DIR$/node_modules/iconv-lite/.travis.yml" afterDir="false" />
23   - <change beforePath="$PROJECT_DIR$/node_modules/iconv-lite/Changelog.md" beforeDir="false" afterPath="$PROJECT_DIR$/node_modules/iconv-lite/Changelog.md" afterDir="false" />
24   - <change beforePath="$PROJECT_DIR$/node_modules/iconv-lite/LICENSE" beforeDir="false" afterPath="$PROJECT_DIR$/node_modules/iconv-lite/LICENSE" afterDir="false" />
25   - <change beforePath="$PROJECT_DIR$/node_modules/iconv-lite/README.md" beforeDir="false" afterPath="$PROJECT_DIR$/node_modules/iconv-lite/README.md" afterDir="false" />
26   - <change beforePath="$PROJECT_DIR$/node_modules/iconv-lite/encodings/dbcs-codec.js" beforeDir="false" afterPath="$PROJECT_DIR$/node_modules/iconv-lite/encodings/dbcs-codec.js" afterDir="false" />
27   - <change beforePath="$PROJECT_DIR$/node_modules/iconv-lite/encodings/dbcs-data.js" beforeDir="false" afterPath="$PROJECT_DIR$/node_modules/iconv-lite/encodings/dbcs-data.js" afterDir="false" />
28   - <change beforePath="$PROJECT_DIR$/node_modules/iconv-lite/encodings/index.js" beforeDir="false" afterPath="$PROJECT_DIR$/node_modules/iconv-lite/encodings/index.js" afterDir="false" />
29   - <change beforePath="$PROJECT_DIR$/node_modules/iconv-lite/encodings/internal.js" beforeDir="false" afterPath="$PROJECT_DIR$/node_modules/iconv-lite/encodings/internal.js" afterDir="false" />
30   - <change beforePath="$PROJECT_DIR$/node_modules/iconv-lite/encodings/sbcs-codec.js" beforeDir="false" afterPath="$PROJECT_DIR$/node_modules/iconv-lite/encodings/sbcs-codec.js" afterDir="false" />
31   - <change beforePath="$PROJECT_DIR$/node_modules/iconv-lite/encodings/sbcs-data-generated.js" beforeDir="false" afterPath="$PROJECT_DIR$/node_modules/iconv-lite/encodings/sbcs-data-generated.js" afterDir="false" />
32   - <change beforePath="$PROJECT_DIR$/node_modules/iconv-lite/encodings/sbcs-data.js" beforeDir="false" afterPath="$PROJECT_DIR$/node_modules/iconv-lite/encodings/sbcs-data.js" afterDir="false" />
33   - <change beforePath="$PROJECT_DIR$/node_modules/iconv-lite/encodings/tables/big5-added.json" beforeDir="false" afterPath="$PROJECT_DIR$/node_modules/iconv-lite/encodings/tables/big5-added.json" afterDir="false" />
34   - <change beforePath="$PROJECT_DIR$/node_modules/iconv-lite/encodings/tables/cp936.json" beforeDir="false" afterPath="$PROJECT_DIR$/node_modules/iconv-lite/encodings/tables/cp936.json" afterDir="false" />
35   - <change beforePath="$PROJECT_DIR$/node_modules/iconv-lite/encodings/tables/cp949.json" beforeDir="false" afterPath="$PROJECT_DIR$/node_modules/iconv-lite/encodings/tables/cp949.json" afterDir="false" />
36   - <change beforePath="$PROJECT_DIR$/node_modules/iconv-lite/encodings/tables/cp950.json" beforeDir="false" afterPath="$PROJECT_DIR$/node_modules/iconv-lite/encodings/tables/cp950.json" afterDir="false" />
37   - <change beforePath="$PROJECT_DIR$/node_modules/iconv-lite/encodings/tables/eucjp.json" beforeDir="false" afterPath="$PROJECT_DIR$/node_modules/iconv-lite/encodings/tables/eucjp.json" afterDir="false" />
38   - <change beforePath="$PROJECT_DIR$/node_modules/iconv-lite/encodings/tables/gbk-added.json" beforeDir="false" afterPath="$PROJECT_DIR$/node_modules/iconv-lite/encodings/tables/gbk-added.json" afterDir="false" />
39   - <change beforePath="$PROJECT_DIR$/node_modules/iconv-lite/encodings/tables/shiftjis.json" beforeDir="false" afterPath="$PROJECT_DIR$/node_modules/iconv-lite/encodings/tables/shiftjis.json" afterDir="false" />
40   - <change beforePath="$PROJECT_DIR$/node_modules/iconv-lite/encodings/utf16.js" beforeDir="false" afterPath="$PROJECT_DIR$/node_modules/iconv-lite/encodings/utf16.js" afterDir="false" />
41   - <change beforePath="$PROJECT_DIR$/node_modules/iconv-lite/encodings/utf7.js" beforeDir="false" afterPath="$PROJECT_DIR$/node_modules/iconv-lite/encodings/utf7.js" afterDir="false" />
42   - <change beforePath="$PROJECT_DIR$/node_modules/iconv-lite/lib/bom-handling.js" beforeDir="false" afterPath="$PROJECT_DIR$/node_modules/iconv-lite/lib/bom-handling.js" afterDir="false" />
43   - <change beforePath="$PROJECT_DIR$/node_modules/iconv-lite/lib/extend-node.js" beforeDir="false" afterPath="$PROJECT_DIR$/node_modules/iconv-lite/lib/extend-node.js" afterDir="false" />
44   - <change beforePath="$PROJECT_DIR$/node_modules/iconv-lite/lib/index.d.ts" beforeDir="false" afterPath="$PROJECT_DIR$/node_modules/iconv-lite/lib/index.d.ts" afterDir="false" />
45   - <change beforePath="$PROJECT_DIR$/node_modules/iconv-lite/lib/index.js" beforeDir="false" afterPath="$PROJECT_DIR$/node_modules/iconv-lite/lib/index.js" afterDir="false" />
46   - <change beforePath="$PROJECT_DIR$/node_modules/iconv-lite/lib/streams.js" beforeDir="false" afterPath="$PROJECT_DIR$/node_modules/iconv-lite/lib/streams.js" afterDir="false" />
47   - <change beforePath="$PROJECT_DIR$/node_modules/iconv-lite/package.json" beforeDir="false" afterPath="$PROJECT_DIR$/node_modules/iconv-lite/package.json" afterDir="false" />
48   - <change beforePath="$PROJECT_DIR$/node_modules/raw-body/HISTORY.md" beforeDir="false" afterPath="$PROJECT_DIR$/node_modules/raw-body/HISTORY.md" afterDir="false" />
49   - <change beforePath="$PROJECT_DIR$/node_modules/raw-body/LICENSE" beforeDir="false" afterPath="$PROJECT_DIR$/node_modules/raw-body/LICENSE" afterDir="false" />
50   - <change beforePath="$PROJECT_DIR$/node_modules/raw-body/README.md" beforeDir="false" afterPath="$PROJECT_DIR$/node_modules/raw-body/README.md" afterDir="false" />
51   - <change beforePath="$PROJECT_DIR$/node_modules/raw-body/index.d.ts" beforeDir="false" afterPath="$PROJECT_DIR$/node_modules/raw-body/index.d.ts" afterDir="false" />
52   - <change beforePath="$PROJECT_DIR$/node_modules/raw-body/index.js" beforeDir="false" afterPath="$PROJECT_DIR$/node_modules/raw-body/index.js" afterDir="false" />
53   - <change beforePath="$PROJECT_DIR$/node_modules/raw-body/node_modules/depd/History.md" beforeDir="false" />
54   - <change beforePath="$PROJECT_DIR$/node_modules/raw-body/node_modules/depd/LICENSE" beforeDir="false" />
55   - <change beforePath="$PROJECT_DIR$/node_modules/raw-body/node_modules/depd/Readme.md" beforeDir="false" />
56   - <change beforePath="$PROJECT_DIR$/node_modules/raw-body/node_modules/depd/index.js" beforeDir="false" />
57   - <change beforePath="$PROJECT_DIR$/node_modules/raw-body/node_modules/depd/lib/browser/index.js" beforeDir="false" />
58   - <change beforePath="$PROJECT_DIR$/node_modules/raw-body/node_modules/depd/lib/compat/callsite-tostring.js" beforeDir="false" />
59   - <change beforePath="$PROJECT_DIR$/node_modules/raw-body/node_modules/depd/lib/compat/event-listener-count.js" beforeDir="false" />
60   - <change beforePath="$PROJECT_DIR$/node_modules/raw-body/node_modules/depd/lib/compat/index.js" beforeDir="false" />
61   - <change beforePath="$PROJECT_DIR$/node_modules/raw-body/node_modules/depd/package.json" beforeDir="false" />
62   - <change beforePath="$PROJECT_DIR$/node_modules/raw-body/node_modules/http-errors/HISTORY.md" beforeDir="false" />
63   - <change beforePath="$PROJECT_DIR$/node_modules/raw-body/node_modules/http-errors/LICENSE" beforeDir="false" />
64   - <change beforePath="$PROJECT_DIR$/node_modules/raw-body/node_modules/http-errors/README.md" beforeDir="false" />
65   - <change beforePath="$PROJECT_DIR$/node_modules/raw-body/node_modules/http-errors/index.js" beforeDir="false" />
66   - <change beforePath="$PROJECT_DIR$/node_modules/raw-body/node_modules/http-errors/package.json" beforeDir="false" />
67   - <change beforePath="$PROJECT_DIR$/node_modules/raw-body/node_modules/setprototypeof/LICENSE" beforeDir="false" />
68   - <change beforePath="$PROJECT_DIR$/node_modules/raw-body/node_modules/setprototypeof/README.md" beforeDir="false" />
69   - <change beforePath="$PROJECT_DIR$/node_modules/raw-body/node_modules/setprototypeof/index.js" beforeDir="false" />
70   - <change beforePath="$PROJECT_DIR$/node_modules/raw-body/node_modules/setprototypeof/package.json" beforeDir="false" />
71   - <change beforePath="$PROJECT_DIR$/node_modules/raw-body/package.json" beforeDir="false" afterPath="$PROJECT_DIR$/node_modules/raw-body/package.json" afterDir="false" />
72   - <change beforePath="$PROJECT_DIR$/package-lock.json" beforeDir="false" afterPath="$PROJECT_DIR$/package-lock.json" afterDir="false" />
73   - <change beforePath="$PROJECT_DIR$/package.json" beforeDir="false" afterPath="$PROJECT_DIR$/package.json" afterDir="false" />
74   - <change beforePath="$PROJECT_DIR$/server.js" beforeDir="false" afterPath="$PROJECT_DIR$/server.js" afterDir="false" />
  8 + <change beforePath="$PROJECT_DIR$/api/models/incident.js" beforeDir="false" afterPath="$PROJECT_DIR$/api/modules/incident.js" afterDir="false" />
  9 + <change beforePath="$PROJECT_DIR$/api/routes/routes.js" beforeDir="false" afterPath="$PROJECT_DIR$/api/routes/routes.js" afterDir="false" />
75 10 </list>
76 11 <option name="EXCLUDED_CONVERTED_TO_IGNORED" value="true" />
77 12 <option name="SHOW_DIALOG" value="false" />
... ... @@ -83,95 +18,76 @@
83 18 <session id="920369055">
84 19 <usages-collector id="statistics.lifecycle.project">
85 20 <counts>
  21 + <entry key="project.closed" value="3" />
  22 + <entry key="project.open.time.16" value="1" />
86 23 <entry key="project.open.time.5" value="1" />
87   - <entry key="project.opened" value="1" />
  24 + <entry key="project.open.time.59" value="1" />
  25 + <entry key="project.opened" value="3" />
88 26 </counts>
89 27 </usages-collector>
90 28 <usages-collector id="statistics.file.extensions.edit">
91 29 <counts>
92   - <entry key="js" value="3243" />
  30 + <entry key="js" value="4909" />
93 31 <entry key="json" value="3" />
94 32 </counts>
95 33 </usages-collector>
96 34 <usages-collector id="statistics.file.types.edit">
97 35 <counts>
98 36 <entry key="JSON" value="3" />
99   - <entry key="JavaScript" value="3243" />
  37 + <entry key="JavaScript" value="4909" />
100 38 </counts>
101 39 </usages-collector>
102 40 <usages-collector id="statistics.file.extensions.open">
103 41 <counts>
104   - <entry key="js" value="5" />
  42 + <entry key="js" value="8" />
105 43 </counts>
106 44 </usages-collector>
107 45 <usages-collector id="statistics.file.types.open">
108 46 <counts>
109   - <entry key="JavaScript" value="5" />
  47 + <entry key="JavaScript" value="8" />
110 48 </counts>
111 49 </usages-collector>
112 50 </session>
113 51 </component>
114 52 <component name="FileEditorManager">
115   - <splitter split-orientation="horizontal" split-proportion="0.5">
116   - <split-first>
117   - <leaf SIDE_TABS_SIZE_LIMIT_KEY="300">
118   - <file pinned="false" current-in-tab="false">
119   - <entry file="file://$PROJECT_DIR$/package.json">
120   - <provider selected="true" editor-type-id="text-editor">
121   - <state relative-caret-position="119">
122   - <caret line="7" column="21" selection-start-line="7" selection-start-column="21" selection-end-line="7" selection-end-column="21" />
123   - </state>
124   - </provider>
125   - </entry>
126   - </file>
127   - <file pinned="false" current-in-tab="false">
128   - <entry file="file://$PROJECT_DIR$/package-lock.json">
129   - <provider selected="true" editor-type-id="text-editor" />
130   - </entry>
131   - </file>
132   - <file pinned="false" current-in-tab="false">
133   - <entry file="file://$PROJECT_DIR$/server.js">
134   - <provider selected="true" editor-type-id="text-editor">
135   - <state>
136   - <caret column="36" selection-start-column="36" selection-end-column="36" />
137   - </state>
138   - </provider>
139   - </entry>
140   - </file>
141   - <file pinned="false" current-in-tab="true">
142   - <entry file="file://$PROJECT_DIR$/api/models/incident.js">
143   - <provider selected="true" editor-type-id="text-editor">
144   - <state relative-caret-position="238">
145   - <caret line="14" lean-forward="true" selection-start-line="14" selection-end-line="14" />
146   - </state>
147   - </provider>
148   - </entry>
149   - </file>
150   - <file pinned="false" current-in-tab="false">
151   - <entry file="file://$PROJECT_DIR$/api/routes/routes.js">
152   - <provider selected="true" editor-type-id="text-editor">
153   - <state relative-caret-position="17">
154   - <caret line="1" column="6" selection-start-line="1" selection-start-column="6" selection-end-line="1" selection-end-column="6" />
155   - </state>
156   - </provider>
157   - </entry>
158   - </file>
159   - </leaf>
160   - </split-first>
161   - <split-second>
162   - <leaf>
163   - <file pinned="false" current-in-tab="true">
164   - <entry file="file://$PROJECT_DIR$/api/routes/routes.js">
165   - <provider selected="true" editor-type-id="text-editor">
166   - <state relative-caret-position="884">
167   - <caret line="52" lean-forward="true" selection-start-line="52" selection-end-line="52" />
168   - </state>
169   - </provider>
170   - </entry>
171   - </file>
172   - </leaf>
173   - </split-second>
174   - </splitter>
  53 + <leaf SIDE_TABS_SIZE_LIMIT_KEY="300">
  54 + <file pinned="false" current-in-tab="true">
  55 + <entry file="file://$PROJECT_DIR$/api/routes/routes.js">
  56 + <provider selected="true" editor-type-id="text-editor">
  57 + <state relative-caret-position="187">
  58 + <caret line="11" column="208" lean-forward="true" selection-start-line="11" selection-start-column="208" selection-end-line="11" selection-end-column="208" />
  59 + </state>
  60 + </provider>
  61 + </entry>
  62 + </file>
  63 + <file pinned="false" current-in-tab="false">
  64 + <entry file="file://$PROJECT_DIR$/api/modules/incident.js">
  65 + <provider selected="true" editor-type-id="text-editor">
  66 + <state relative-caret-position="153">
  67 + <caret line="9" column="1" selection-start-line="9" selection-start-column="1" selection-end-line="9" selection-end-column="1" />
  68 + </state>
  69 + </provider>
  70 + </entry>
  71 + </file>
  72 + <file pinned="false" current-in-tab="false">
  73 + <entry file="file://$PROJECT_DIR$/api/modules/activity.js">
  74 + <provider selected="true" editor-type-id="text-editor">
  75 + <state>
  76 + <caret column="19" selection-start-column="19" selection-end-column="19" />
  77 + </state>
  78 + </provider>
  79 + </entry>
  80 + </file>
  81 + <file pinned="false" current-in-tab="false">
  82 + <entry file="file://$PROJECT_DIR$/api/modules/evaluation.js">
  83 + <provider selected="true" editor-type-id="text-editor">
  84 + <state relative-caret-position="170">
  85 + <caret line="10" column="1" selection-start-line="10" selection-start-column="1" selection-end-line="10" selection-end-column="1" />
  86 + </state>
  87 + </provider>
  88 + </entry>
  89 + </file>
  90 + </leaf>
175 91 </component>
176 92 <component name="FileTemplateManagerImpl">
177 93 <option name="RECENT_TEMPLATES">
... ... @@ -180,6 +96,12 @@
180 96 </list>
181 97 </option>
182 98 </component>
  99 + <component name="FindInProjectRecents">
  100 + <findStrings>
  101 + <find>get</find>
  102 + <find>.get</find>
  103 + </findStrings>
  104 + </component>
183 105 <component name="Git.Settings">
184 106 <option name="RECENT_GIT_ROOT_PATH" value="$PROJECT_DIR$/.." />
185 107 </component>
... ... @@ -204,6 +126,9 @@
204 126 <option value="$PROJECT_DIR$/api/models/Incident.js" />
205 127 <option value="$PROJECT_DIR$/api/models/models.js" />
206 128 <option value="$PROJECT_DIR$/api/models/incident.js" />
  129 + <option value="$PROJECT_DIR$/api/modules/incident.js" />
  130 + <option value="$PROJECT_DIR$/api/modules/evaluation.js" />
  131 + <option value="$PROJECT_DIR$/api/modules/activity.js" />
207 132 <option value="$PROJECT_DIR$/api/routes/routes.js" />
208 133 </list>
209 134 </option>
... ... @@ -253,7 +178,7 @@
253 178 <item name="restApi" type="b2602c69:ProjectViewProjectNode" />
254 179 <item name="restApi" type="462c0819:PsiDirectoryNode" />
255 180 <item name="api" type="462c0819:PsiDirectoryNode" />
256   - <item name="models" type="462c0819:PsiDirectoryNode" />
  181 + <item name="modules" type="462c0819:PsiDirectoryNode" />
257 182 </path>
258 183 <path>
259 184 <item name="restApi" type="b2602c69:ProjectViewProjectNode" />
... ... @@ -377,16 +302,17 @@
377 302 <updated>1538753503688</updated>
378 303 <workItem from="1538753505199" duration="609000" />
379 304 <workItem from="1538754856928" duration="649000" />
380   - <workItem from="1538838941552" duration="9343000" />
  305 + <workItem from="1538838941552" duration="10339000" />
  306 + <workItem from="1538928470276" duration="5791000" />
  307 + <workItem from="1538934478875" duration="76000" />
381 308 </task>
382 309 <servers />
383 310 </component>
384 311 <component name="TimeTrackingManager">
385   - <option name="totallyTimeSpent" value="10601000" />
  312 + <option name="totallyTimeSpent" value="17464000" />
386 313 </component>
387 314 <component name="ToolWindowManager">
388 315 <frame x="-8" y="-8" width="2576" height="1416" extended-state="6" />
389   - <editor active="true" />
390 316 <layout>
391 317 <window_info active="true" content_ui="combo" id="Project" order="0" visible="true" weight="0.19897558" />
392 318 <window_info id="Structure" order="1" weight="0.25" />
... ... @@ -416,9 +342,9 @@
416 342 <option name="myLimit" value="2678400000" />
417 343 </component>
418 344 <component name="editorHistoryManager">
419   - <entry file="file://$PROJECT_DIR$/package-lock.json">
420   - <provider selected="true" editor-type-id="text-editor" />
421   - </entry>
  345 + <entry file="file://$PROJECT_DIR$/api/models/evaluationModel.js" />
  346 + <entry file="file://$PROJECT_DIR$/api/models/models.js" />
  347 + <entry file="file://$PROJECT_DIR$/api/controllers/evaluationController.js" />
422 348 <entry file="file://$PROJECT_DIR$/package.json">
423 349 <provider selected="true" editor-type-id="text-editor">
424 350 <state relative-caret-position="119">
... ... @@ -426,37 +352,41 @@
426 352 </state>
427 353 </provider>
428 354 </entry>
429   - <entry file="file://$PROJECT_DIR$/api/models/evaluationModel.js">
  355 + <entry file="file://$PROJECT_DIR$/package-lock.json">
430 356 <provider selected="true" editor-type-id="text-editor" />
431 357 </entry>
432   - <entry file="file://$PROJECT_DIR$/api/models/models.js">
  358 + <entry file="file://$PROJECT_DIR$/server.js">
433 359 <provider selected="true" editor-type-id="text-editor">
434   - <state relative-caret-position="17">
435   - <caret line="1" lean-forward="true" selection-start-line="1" selection-end-line="1" />
  360 + <state relative-caret-position="272">
  361 + <caret line="16" column="3" selection-start-line="16" selection-start-column="3" selection-end-line="16" selection-end-column="3" />
436 362 </state>
437 363 </provider>
438 364 </entry>
439   - <entry file="file://$PROJECT_DIR$/server.js">
  365 + <entry file="file://$PROJECT_DIR$/api/routes/routes.js">
440 366 <provider selected="true" editor-type-id="text-editor">
441   - <state>
442   - <caret column="36" selection-start-column="36" selection-end-column="36" />
  367 + <state relative-caret-position="187">
  368 + <caret line="11" column="208" lean-forward="true" selection-start-line="11" selection-start-column="208" selection-end-line="11" selection-end-column="208" />
443 369 </state>
444 370 </provider>
445 371 </entry>
446   - <entry file="file://$PROJECT_DIR$/api/controllers/evaluationController.js">
447   - <provider selected="true" editor-type-id="text-editor" />
  372 + <entry file="file://$PROJECT_DIR$/api/modules/incident.js">
  373 + <provider selected="true" editor-type-id="text-editor">
  374 + <state relative-caret-position="153">
  375 + <caret line="9" column="1" selection-start-line="9" selection-start-column="1" selection-end-line="9" selection-end-column="1" />
  376 + </state>
  377 + </provider>
448 378 </entry>
449   - <entry file="file://$PROJECT_DIR$/api/routes/routes.js">
  379 + <entry file="file://$PROJECT_DIR$/api/modules/activity.js">
450 380 <provider selected="true" editor-type-id="text-editor">
451   - <state relative-caret-position="17">
452   - <caret line="1" column="6" selection-start-line="1" selection-start-column="6" selection-end-line="1" selection-end-column="6" />
  381 + <state>
  382 + <caret column="19" selection-start-column="19" selection-end-column="19" />
453 383 </state>
454 384 </provider>
455 385 </entry>
456   - <entry file="file://$PROJECT_DIR$/api/models/incident.js">
  386 + <entry file="file://$PROJECT_DIR$/api/modules/evaluation.js">
457 387 <provider selected="true" editor-type-id="text-editor">
458   - <state relative-caret-position="238">
459   - <caret line="14" lean-forward="true" selection-start-line="14" selection-end-line="14" />
  388 + <state relative-caret-position="170">
  389 + <caret line="10" column="1" selection-start-line="10" selection-start-column="1" selection-end-line="10" selection-end-column="1" />
460 390 </state>
461 391 </provider>
462 392 </entry>
... ...
restApi/Deployment Diagram.docx 0 → 100644
No preview for this file type
restApi/README.txt 0 → 100644
  1 +How to run the server:
  2 +
  3 +1 - This is a node.js server so node is required. https://nodejs.org/en/download/
  4 +2 - Start Windows Powershell on windows or terminal on Mac.
  5 +3 - Navigate to this folder (.....\ITE1893_Risikovurdering_Gruppe4\restApi)
  6 +4 - Use command: "npm run api"
  7 +5 - The server should start running on localhost and listen to port 3000 (and should auto-restart if changes are made in the code)
  8 +6 - Endpoints are documented in the code (routes.js)
  9 +7 - Use Postman to test endpoints where a body is expected
0 10 \ No newline at end of file
... ...
restApi/api/modules/activity.js 0 → 100644
  1 +var object = Activity.prototype;
  2 +
  3 +function Activity(id, title) {
  4 + this.id = id;
  5 + this.title = title;
  6 +}
  7 +
  8 +module.exports = Activity;
0 9 \ No newline at end of file
... ...
restApi/api/modules/evaluation.js 0 → 100644
  1 +var object = Evaluation.prototype;
  2 +
  3 +function Evaluation(id, title, outcome, measures, consequence, probabillity, associatedActivity) {
  4 + this.id = id;
  5 + this.title = title;
  6 + this.outcome = outcome;
  7 + this.measures = measures;
  8 + this.consequence = consequence;
  9 + this.probability = probabillity;
  10 + this.associatedActivity = associatedActivity;
  11 +}
  12 +
  13 +module.exports = Evaluation;
0 14 \ No newline at end of file
... ...
restApi/api/models/incident.js renamed to restApi/api/modules/incident.js
... ... @@ -9,28 +9,4 @@ function Incident(id, date, location, title, description, associatedEval) {
9 9 this.associatedEval = associatedEval;
10 10 }
11 11  
12   -object.getId = function() {
13   - return this.id;
14   -};
15   -
16   -object.getDate = function() {
17   - return this.date;
18   -};
19   -
20   -object.getLocation = function() {
21   - return this.location;
22   -};
23   -
24   -object.getTitle = function() {
25   - return this.title;
26   -};
27   -
28   -object.getDescription = function() {
29   - return this.description;
30   -};
31   -
32   -object.getAssociatedEval = function() {
33   - return this.associatedEval;
34   -};
35   -
36 12 module.exports = Incident;
37 13 \ No newline at end of file
... ...
restApi/api/routes/routes.js
1 1 //All endpoints will be defined in this file
2   -const Incident = require("../models/incident.js");
  2 +const Incident = require("../modules/incident.js");
  3 +
3 4 var mockIncidents = [
4 5 new Incident("1", "03.03.2018", "Bodø", "Datt på isen", "Datt på isen når jeg skuplle gå til bilen", "4"),
5 6 new Incident("2", "11.11.2012", "Oslo", "Bilkræsj", "Kræsjet med en annen bil", "2"),
... ... @@ -8,19 +9,21 @@ var mockIncidents = [
8 9  
9 10 var appRouter = function(app) {
10 11  
  12 + //Made only methods for Incident for demonstration. Other methods can be easily added later when we actually need to use them (there is no point in making them with mock if they are not gonna be used yet)
  13 +
11 14 //Root endpoint (http://localhost:3000)
12 15 app.get("/", function(req, res) {
13 16 res.send("Evaluation API by Ali, Kristin and Anna is up and running...");
14 17 });
15 18  
16   - //Get incident by id endpoint (http://localhost:3000/getIncident?id=1 will return the mock object)
  19 + //Get incident by id endpoint (http://localhost:3000/getIncident?id=1 will return the mock object with id 1)
17 20 app.get("/getIncident", function (req, res) {
18 21  
19 22 var foundIncident = null;
20 23  
21 24 //Search the array with mockIncidents and if id is found stop the loop and set foundIncident variable
22 25 mockIncidents.forEach(function (value) {
23   - if (value.getId() === req.query.id) {
  26 + if (value.id === req.query.id) {
24 27 foundIncident = value;
25 28 return true;
26 29 }
... ... @@ -40,6 +43,8 @@ var appRouter = function(app) {
40 43  
41 44 //Add a ned incident (http://localhost:3000/addIncident - with an "x-www-form-urlencoded" body of params)
42 45 app.post("/addIncident", function(req, res) {
  46 +
  47 + // All these parameters must exist in the body with the exact name for this method to work
43 48 if(!req.body.id || !req.body.date || !req.body.location || !req.body.title || !req.body.description || !req.body.associatedEval) {
44 49 return res.send({"status": "error", "message": "missing a parameters"});
45 50 } else {
... ... @@ -51,8 +56,37 @@ var appRouter = function(app) {
51 56 }
52 57 });
53 58  
54   - app.patch("/changeIncidentTitle", function (req, res) {
  59 + //Update an incident (http://localhost:3000/updateIncident?id=1 will update the incident with id=1 with the params passed in the request body)
  60 + app.patch("/updateIncident", function (req, res) {
  61 + var foundIncident = null;
  62 +
  63 + //Search the array with mockIncidents and if id is found stop the loop and set foundIncident variable
  64 + mockIncidents.forEach(function (value) {
  65 + if (value.id === req.query.id) {
  66 + foundIncident = value;
  67 + return true;
  68 + }
  69 +
  70 + //Only mock so nothing is really happening here, here the database should be updated
  71 + if (foundIncident != null) {
  72 + if (req.body.date !== null) foundIncident.date = req.body.date;
  73 + if (req.body.location !== null) foundIncident.location = req.body.location;
  74 + if (req.body.title !== null) foundIncident.title = req.body.title;
  75 + if (req.body.description !== null) foundIncident.description = req.body.description;
  76 + if (req.body.associatedEval !== null) foundIncident.associatedEval = req.body.associatedEval;
  77 + return res.send({"status": "success", "message": "Incident updated"});
  78 + }
  79 +
  80 + return res.send({"status": "error", "message": "Id missing"});
  81 +
  82 + });
  83 + });
  84 +
  85 + //Delete an incident (http://localhost:3000/deleteIncident?id=1 should delete incident with id=1)
  86 + app.delete("/deleteIncident", function (req, res) {
  87 + if (!req.query.id) return res.send({"status": "failed", "message": "Id missing"});
55 88  
  89 + return res.send({"status": "success", "message": "Nothing really deleted because this is a mock server but this should delete incident with id: " + req.query.id});
56 90 });
57 91  
58 92 };
... ...