-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
865 lines (774 loc) · 30.5 KB
/
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>Wroctab - Document Management System Index</title>
<!--[if lt IE 9]>
<script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script>
<![endif]-->
<link type="text/css" rel="stylesheet" href="styles/sunlight.default.css">
<link type="text/css" rel="stylesheet" href="styles/site.flatly.css">
</head>
<body>
<div class="navbar navbar-default navbar-fixed-top ">
<div class="container">
<div class="navbar-header">
<a class="navbar-brand" href="index.html">Wroctab - Document Management System</a>
<button class="navbar-toggle" type="button" data-toggle="collapse" data-target="#topNavigation">
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
</div>
<div class="navbar-collapse collapse" id="topNavigation">
<ul class="nav navbar-nav">
<li class="dropdown">
<a href="global.html" class="dropdown-toggle" data-toggle="dropdown">Global<b class="caret"></b></a>
<ul class="dropdown-menu ">
<li><a href="global.html#Helpers">Helpers</a></li><li><a href="global.html#imgpath">imgpath</a></li>
</ul>
</li>
</ul>
<div class="col-sm-3 col-md-3">
<form class="navbar-form" role="search">
<div class="input-group">
<input type="text" class="form-control" placeholder="Search" name="q" id="search-input">
<div class="input-group-btn">
<button class="btn btn-default" id="search-submit"><i class="glyphicon glyphicon-search"></i></button>
</div>
</div>
</form>
</div>
</div>
</div>
</div>
<div class="container" id="toc-content">
<div class="row">
<div class="col-md-8">
<div id="main">
<section class="readme-section">
<article><h1>Woctab - Document Management System</h1><p>Wroctab is a full stack document management system that helps to manage documents given the different accessibility. Wroctab contains a backend API developed with Node, Express and Sequelize. A frontend developed with React using Redux architecture.</p>
<h2>Development</h2><p>This application was developed using the following frameworks.</p>
<ul>
<li><a href="https://nodejs.org">NodeJs</a></li>
<li><a href="http://redux.js.org/docs/basics/UsageWithReact.html">React Redux</a></li>
<li><a href="https://webpack.js.org/">Webpack</a></li>
<li><a href="https://expressjs.com/">express</a></li>
<li><a href="https://sequelizejs.org">Sequelize</a> as <a href="https://en.wikipedia.org/wiki/Object-relational_mapping">ORM</a></li>
</ul>
<h2>Application Features</h2><h6>User Authentication</h6><p>Users are authenticated and validated using JWT web token. Generating tokens on signup and login ensures documents and API endpoints are protected.</p>
<h6>Document Management</h6><ul>
<li>Create an account</li>
<li>Login with your credentials</li>
<li>Create new document specifying document title, content and document access</li>
<li>Edit Documents</li>
<li>Delete documents</li>
<li>View public documents created by other users.</li>
<li>View documents created by his access group with access level set as <code>role</code>.</li>
<li>Search a users public documents.</li>
<li>View <code>public</code> and <code>role</code> access level documents of other regular users.</li>
<li>Share document with specific user(s) - Upcoming</li>
<li><p>Logout</p>
</li>
<li><p>In addition to the general user functions, an admin user can:</p>
<ul>
<li>View all users.</li>
<li>View all created documents except documents with access set to private.</li>
<li>Delete any user.</li>
<li>Update any user's record.</li>
<li>Create a new role.</li>
<li>View all created roles.</li>
<li>Search for any user.</li>
</ul>
</li>
</ul>
<h2>Installation</h2><ul>
<li>Ensure that you have NodeJs and Postgres installed on your machine</li>
<li>Clone the repository <code>$ git clone https://github.com/andela-aonifade/wroctab.git</code></li>
<li>Change into the directory <code>$ cd wroctab</code></li>
<li>Install all required dependencies with <code>$ npm install</code></li>
<li>Create a <code>.env</code> file in your root directory as described in <code>.env.sample</code> file</li>
</ul>
<h2>Usage</h2><ul>
<li>Run DB Migrate command with <code>sequelize db:migrate</code></li>
<li>Seed you DB by running this command <code>npm run db:seed</code>, this seeds Admin Role and Regular Role.</li>
<li>Run <code>npm run start:dev</code> to start the application on development environment</li>
</ul>
<h2>Testing</h2><ul>
<li>Run DB migrate command with <code>npm run db:migrate:test</code>.</li>
<li>Run Test <code>npm test</code></li>
<li>You can undo your migrations by running this command <code>npm run db:migrate:test:undo</code>.</li>
</ul>
<p><code>Use a separate DB for testing and development</code></p>
<h2>API Documentation</h2><hr>
<p>The API has routes, each dedicated to a single task that uses HTTP response codes to indicate API status and errors.</p>
<h4>API Features</h4><p>The following features make up the Document Management System API:</p>
<h6>Authentication</h6><ul>
<li><p>It uses JSON Web Token (JWT) for authentication. </p>
</li>
<li><p>It generates a token on successful login or account creation and returns it to the consumer. </p>
</li>
<li><p>It verifies the token to ensures a user is authenticated to access protected endpoints.</p>
</li>
</ul>
<h6>Users</h6><ul>
<li><p>It allows users to be created. </p>
</li>
<li><p>It allows users to login and obtain a token </p>
</li>
<li><p>It allows authenticated users to retrieve and update their information. </p>
</li>
<li><p>It allows the admin to manage users.</p>
</li>
</ul>
<h6>Roles</h6><ul>
<li>It ensures roles can be created, retrieved, updated and deleted by an admin user.</li>
<li>A non-admin user cannot create, retrieve, modify, or delete roles. </li>
<li>it allows for assignment of roles to users</li>
</ul>
<h6>Documents</h6><ul>
<li><p>It allows new documents to be created by authenticated users. </p>
</li>
<li><p>It ensures all documents are accessible based on the permission specified. </p>
</li>
<li><p>It allows admin users to create, retrieve, modify, and delete documents.</p>
</li>
</ul>
<ul>
<li><p>It ensures users can delete, edit and update documents that they own. </p>
</li>
<li><p>It allows users to retrieve all documents they own as well as public documents.</p>
</li>
</ul>
<h6>Search</h6><ul>
<li><p>It allows users to search public documents for a specified search term.</p>
</li>
<li><p>It allows admin to retrieve all documents that matches search term.</p>
</li>
<li><p>It allows admin to search users based on a specified search term</p>
</li>
</ul>
<h4>Available API Endpoints and their Functionality</h4><table>
<thead>
<tr>
<th>EndPoint</th>
<th>Functionality</th>
</tr>
</thead>
<tbody>
<tr>
<td>POST /users/login</td>
<td>Logs a user in.</td>
</tr>
<tr>
<td>POST /users/logout</td>
<td>Logs a user out.</td>
</tr>
<tr>
<td>POST /users/</td>
<td>Creates a new user.</td>
</tr>
<tr>
<td>GET /users/</td>
<td>Find matching instances of user.</td>
</tr>
<tr>
<td>GET /users/<id></td>
<td>Find user.</td>
</tr>
<tr>
<td>PUT /users/<id></td>
<td>Update user attributes.</td>
</tr>
<tr>
<td>DELETE /users/<id></td>
<td>Delete user.</td>
</tr>
<tr>
<td>GET /users/?limit={interger}&offset={interger}</td>
<td>Pagination for users</td>
</tr>
<tr>
<td>POST /documents/</td>
<td>Creates a new document instance.</td>
</tr>
<tr>
<td>GET /documents/</td>
<td>Find matching instances of document.</td>
</tr>
<tr>
<td>GET /documents/<id></td>
<td>Find document.</td>
</tr>
<tr>
<td>GET /documents/?limit={interger}&offset={interger}</td>
<td>Pagination for documents</td>
</tr>
<tr>
<td>PUT /documents/<id></td>
<td>Update document attributes.</td>
</tr>
<tr>
<td>DELETE /documents/<id></td>
<td>Delete document.</td>
</tr>
<tr>
<td>GET /users/<id>/documents</td>
<td>Find all documents belonging to the user.</td>
</tr>
<tr>
<td>GET /search/users/?q={username}</td>
<td>Gets all users with username contain the search term</td>
</tr>
<tr>
<td>GET /search/documents/?q={doctitle}</td>
<td>Get all documents with title containing the search query</td>
</tr>
<tr>
<td>GET /users/:id/alldocuments</td>
<td>Get all document owned or accessible by <code>userId</code></td>
</tr>
<tr>
<td>GET /api/users/:identifier</td>
<td>Find user with email or username containing the identifier parameter</td>
</tr>
</tbody>
</table>
<h4>Role</h4><h6>POST HTTP Request</h6><ul>
<li><code>POST /roles</code></li>
<li>Requires: Admin Authentication<h6>HTTP Response</h6></li>
<li>HTTP Status: <code>201: created</code></li>
<li>JSON data<pre class="prettyprint source lang-json"><code>{
"role": {
"id": 12,
"title": "moderator",
"updatedAt": "2017-06-05T11:04:42.604Z",
"createdAt": "2017-06-05T11:04:42.604Z"
},
"message": "Role created succesfully"
}</code></pre><h6>GET HTTP Request</h6></li>
<li><code>GET /roles/:id</code></li>
<li>Requires: Authentication<h6>HTTP Response</h6></li>
<li>HTTP Status: <code>200: OK</code></li>
<li>JSON data<pre class="prettyprint source lang-json"><code>{
"role": {
"id": 2,
"title": "regular",
"createdAt": "2017-05-18T15:31:39.062Z",
"updatedAt": "2017-05-18T15:31:39.062Z"
}
}</code></pre><h6>GET HTTP Request</h6></li>
<li><code>GET /roles</code></li>
<li>Requires: Admin Authentication<h6>HTTP Response</h6></li>
<li>HTTP Status: <code>200: OK</code></li>
<li>JSON data<pre class="prettyprint source lang-json"><code>{
"role": [
{
"id": 1,
"title": "administrator",
"createdAt": "2017-05-18T15:31:39.062Z",
"updatedAt": "2017-05-18T15:31:39.062Z"
},
{
"id": 2,
"title": "regular",
"createdAt": "2017-05-18T15:31:39.062Z",
"updatedAt": "2017-05-18T15:31:39.062Z"
},
{
"id": 11,
"title": "general",
"createdAt": "2017-05-20T13:28:18.851Z",
"updatedAt": "2017-05-20T13:28:18.851Z"
}
]
}</code></pre><h6>PUT HTTP Request</h6></li>
<li><code>PUT /roles/:id</code></li>
<li>Requires: Admin Authentication<h6>HTTP Response</h6></li>
<li>HTTP Status: <code>200: OK</code></li>
<li>JSON data<pre class="prettyprint source lang-json"><code>{
"role": {
"id": 12,
"title": "Document moderator",
"createdAt": "2017-06-05T11:04:42.604Z",
"updatedAt": "2017-06-05T11:15:38.862Z"
},
"message": "Role updated successfully."
}</code></pre><h6>DELETE HTTP Request</h6></li>
<li><code>DELETE /roles/:id</code></li>
<li>Requires: Admin Authentication<h6>HTTP Response</h6></li>
<li>HTTP Status: <code>200: OK</code></li>
<li>JSON data<pre class="prettyprint source lang-json"><code>{
"message": "Role deleted successfully."
}</code></pre></li>
</ul>
<h4>Users</h4><h6>POST HTTP Request</h6><ul>
<li><code>POST /users</code><h6>HTTP response</h6></li>
<li>HTTP Status: <code>201: created</code></li>
<li>JSON data<pre class="prettyprint source lang-json"><code>{
"newUser": {
"id": 16,
"name": "Anu",
"username": "anu",
"email": "[email protected]",
"password": "$2a$08$RFZplY48i2LfrskVaaYb6ehZTHujHdBW7N14faSSCWsTK7fhWnyOG",
"roleId": 1,
"updatedAt": "2017-06-05T10:54:59.750Z",
"createdAt": "2017-06-05T10:54:59.750Z"
},
"message": "User created successfully",
"token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJkYXRhIjp7ImlkIjoxNiwibmFtZSI6IkFudSIsInVzZXJuYW1lIjoiYW51IiwiZW1haWwiOiJhbnVAYW51LmNvbSIsInJvbGVJZCI6MX0sImlhdCI6MTQ5NjY2MDA5OSwiZXhwIjoxNDk2NzQ2NDk5fQ.IWMSKLvMby1yek0hEiSJmS7mWTV7m5Lp23lZlrI5hq4"
}</code></pre><h6>Login HTTP Request</h6></li>
<li><code>POST /users/login</code><h6>HTTP Response</h6></li>
<li>HTTP status: <code>200: OK</code></li>
<li>JSON Data<pre class="prettyprint source lang-json"><code>{
"message": "User authenticated successfully",
"token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJkYXRhIjp7ImlkIjoxNSwibmFtZSI6ImFkbWluIHVzZXIiLCJ1c2VybmFtZSI6ImFkbWluMSIsImVtYWlsIjoiYWRtaW4yQGFkbWluMi5jb20iLCJyb2xlSWQiOjF9LCJpYXQiOjE0OTY0MzEwMDcsImV4cCI6MTQ5NjUxNzQwN30.M5UKTYZb9m4YHeIRXlyRPQb8y66hMF65v7tV1SGmLfg"
}</code></pre></li>
</ul>
<h4>Get Users</h4><h6>GET HTTP Request</h6><ul>
<li><code>GET /users</code></li>
<li>Requires: Admin Authentication<h6>HTTP Response</h6></li>
<li>HTTP status: <code>200: OK</code></li>
<li>JSON Data<pre class="prettyprint source lang-json"><code>{
"user": [
{
"id": 4,
"name": "Anthony",
"username": "anthony",
"email": "[email protected]",
"password": "$2a$10$oGsHABwrr34AVZfdDN1WG.r/jHryU/QsO2p4I9t3HtUKCx.Sc0GGG",
"roleId": 2,
"createdAt": "2017-05-18T15:33:21.224Z",
"updatedAt": "2017-05-18T15:33:21.224Z"
},
{
"id": 2,
"name": "Onifade anuoluwapo",
"username": "anuonifade",
"email": "[email protected]",
"password": "$2a$10$heCyCbBosnmoaIvXiFmMoeIA6L0.TkeFSZ4YWAivvRGutQf8Wca8O",
"roleId": 1,
"createdAt": "2017-05-18T15:31:39.064Z",
"updatedAt": "2017-05-18T15:31:39.072Z"
},
{
"id": 6,
"name": "abc",
"username": "abc",
"email": "[email protected]",
"password": "$2a$10$/24arX4OjmSQewRRBDOkY./.FWhaXFLlpnY/mu1T6Ll2VKBdaYKsa",
"roleId": 11,
"createdAt": "2017-05-20T19:30:23.180Z",
"updatedAt": "2017-05-20T19:30:23.180Z"
},
{
"id": 7,
"name": "taiwo",
"username": "taiwo",
"email": "[email protected]",
"password": "$2a$10$DwpNblV54MF5uMKGobh8iu7Ig9IimSx8InnhcGlTwFHnJtXurx3O.",
"roleId": 2,
"createdAt": "2017-05-22T07:32:14.867Z",
"updatedAt": "2017-05-22T07:32:14.867Z"
},
{
"id": 8,
"name": "Anu Onifade",
"username": "anuonifade1",
"email": "[email protected]",
"password": "$2a$10$RwYO4eeUDjQhcXrPzS.xSOehGF1tej0JW.Uly2Q7hH3adfiAHEpmi",
"roleId": 2,
"createdAt": "2017-05-23T14:48:13.596Z",
"updatedAt": "2017-05-23T14:48:13.596Z"
},
{
"id": 9,
"name": "weirdo maximuf",
"username": "weirdo",
"email": "[email protected]",
"password": "$2a$08$cOB.fHHM3z4aZnNXoCkgkOxsZrPfYRerQB9CNGemta1VrFimEbzq2",
"roleId": 2,
"createdAt": "2017-05-25T13:55:34.381Z",
"updatedAt": "2017-05-25T13:58:02.523Z"
},
{
"id": 11,
"name": "Super Administrator",
"username": "superadmin",
"email": "[email protected]",
"password": "$2a$08$eP3vyNCEkIetLGMb1JfGce8L5uku45L2NtnLOReNaAiAkKfpw2i3y",
"roleId": 1,
"createdAt": "2017-05-26T20:20:51.617Z",
"updatedAt": "2017-05-26T20:20:51.617Z"
},
{
"id": 1,
"name": "administrator user",
"username": "admin",
"email": "[email protected]",
"password": "$2a$08$DsSJvQdzWp8iagIpgKfE7uf8BPWje80KAzqX2hgm0AwAXjM9A0xcC",
"roleId": 1,
"createdAt": "2017-05-18T15:31:39.064Z",
"updatedAt": "2017-06-02T18:23:26.445Z"
},
{
"id": 12,
"name": "abcd",
"username": "abcd",
"email": "[email protected]",
"password": "$2a$08$QNz.g.245Q6DZr6N0daDlukw/9mnrAgyAsG1k.iC1QlDHdYV3vBK.",
"roleId": 1,
"createdAt": "2017-05-30T17:29:34.144Z",
"updatedAt": "2017-05-30T17:30:06.864Z"
},
{
"id": 15,
"name": "admin user",
"username": "admin1",
"email": "[email protected]",
"password": "$2a$10$kzOTNdcyeaXcFj3.BUOSv.svbjKO4qvvt3QD0ABu6CeLY5D6.g77O",
"roleId": 1,
"createdAt": "2017-06-02T19:01:30.956Z",
"updatedAt": "2017-06-02T22:05:44.757Z"
}
],
"pagination": {
"limit": 10,
"next": "?limit=10&offset=10",
"offset": 0,
"previous": "?limit=10&offset=0",
"total_count": 12
}
}</code></pre><h4>Get User</h4><h6>GET HTTP Request</h6></li>
<li><code>GET /users/:id</code></li>
<li>Requires: Admin Authentication<h6>HTTP Response</h6></li>
<li>HTTP status: <code>200: OK</code></li>
<li>JSON Data<pre class="prettyprint source lang-json"><code>{
"user":
{
"id": 8,
"name": "Anu Onifade",
"username": "anuonifade1",
"email": "[email protected]",
"password": "$2a$10$RwYO4eeUDjQhcXrPzS.xSOehGF1tej0JW.Uly2Q7hH3adfiAHEpmi",
"roleId": 2,
"createdAt": "2017-05-23T14:48:13.596Z",
"updatedAt": "2017-05-23T14:48:13.596Z"
}
}</code></pre><h4>Update User</h4><h6>PUT HTTP Request</h6></li>
<li><code>PUT /users/:id</code></li>
<li>Requires: Authentication<h6>HTTP Response</h6></li>
<li>HTTP status: <code>200: OK</code></li>
<li>JSON Data<pre class="prettyprint source lang-json"><code>{
"updatedUser": {
"id": 7,
"name": "taiwo",
"username": "taiwo",
"email": "[email protected]",
"password": "$2a$10$V1WWEG3FU9hbVONZoeQhKeWZmvoCklwBbFxHru/QCBMORsdc4bVwi",
"roleId": 2,
"createdAt": "2017-05-22T07:32:14.867Z",
"updatedAt": "2017-06-05T11:36:09.966Z"
},
"message": "User updated successfully"
}</code></pre><h4>Delete User</h4><h6>DELETE HTTP Request</h6></li>
<li><code>DELETE /users/:id</code></li>
<li>Requires: Admin Authentication<h6>HTTP Response</h6></li>
<li>HTTP status: <code>200: OK</code></li>
<li>JSON Data<pre class="prettyprint source lang-json"><code>{
"message": "abcd deleted successfully"
}</code></pre></li>
</ul>
<h4>Documents</h4><h6>POST HTTP Request</h6><ul>
<li><code>POST /documents</code></li>
<li>Requires: Authentication<h6>HTTP response</h6></li>
<li>HTTP Status: <code>201: created</code></li>
<li>JSON data<pre class="prettyprint source lang-json"><code>{
"id": "1",
"title": "Test Title",
"docContent": "This is my first diary created on this application",
"viewAccess": "private",
"role": "1",
"userId": "1",
"createdAT": "2017-04-05T14:22:46.984z",
"updatedAT": "2017-04-05T14:22:46.984z"
}</code></pre><h6>GET HTTP Request</h6></li>
<li><code>GET /documents</code><h6>HTTP response</h6></li>
<li>HTTP Status: <code>200: 0k</code></li>
<li>JSON data<pre class="prettyprint source lang-json"><code>{
"message": "Documents loaded successfully",
"document": [
{
"id": 5,
"title": "test taiwo",
"docContent": "<p>this is taiwo in the house yeah.</p>",
"docType": null,
"viewAccess": "public",
"role": "2",
"createdAt": "2017-05-22T07:33:25.307Z",
"updatedAt": "2017-05-22T07:33:25.307Z",
"userId": 7,
"User": {
"id": 7,
"name": "taiwo",
"username": "taiwo",
"email": "[email protected]",
"password": "$2a$10$V1WWEG3FU9hbVONZoeQhKeWZmvoCklwBbFxHru/QCBMORsdc4bVwi",
"roleId": 2,
"createdAt": "2017-05-22T07:32:14.867Z",
"updatedAt": "2017-06-05T11:36:09.966Z"
}
},
{
"id": 2,
"title": "Norem ipsum 1",
"docContent": "<p>Nisi et et blanditiis dignissimos quia enim sit tenetur. Quasi molestiae aut veritatis id omnis ipsa odio accusamus. Voluptatem corrupti rem. Atque consequatur occaecati beatae ipsa sunt dolores dolor nostrum et. Ut blanditiis et reiciendis vel facere neque iste. Tenetur vero reiciendis reprehenderit.</p>",
"docType": null,
"viewAccess": "public",
"role": "1",
"createdAt": "2017-05-18T15:31:39.401Z",
"updatedAt": "2017-05-20T17:23:06.305Z",
"userId": 1,
"User": {
"id": 1,
"name": "administrator user",
"username": "admin",
"email": "[email protected]",
"password": "$2a$08$DsSJvQdzWp8iagIpgKfE7uf8BPWje80KAzqX2hgm0AwAXjM9A0xcC",
"roleId": 1,
"createdAt": "2017-05-18T15:31:39.064Z",
"updatedAt": "2017-06-02T18:23:26.445Z"
}
},
{
"id": 4,
"title": "test",
"docContent": "<p>test</p>",
"docType": null,
"viewAccess": "public",
"role": "2",
"createdAt": "2017-05-18T21:35:09.415Z",
"updatedAt": "2017-05-18T21:35:09.415Z",
"userId": null,
"User": null
},
{
"id": 3,
"title": "Hello Document Ngene",
"docContent": "<p>Ngene created this document</p>",
"docType": null,
"viewAccess": "private",
"role": "2",
"createdAt": "2017-05-18T15:34:26.700Z",
"updatedAt": "2017-05-18T15:34:44.111Z",
"userId": 4,
"User": {
"id": 4,
"name": "Anthony",
"username": "anthony",
"email": "[email protected]",
"password": "$2a$10$oGsHABwrr34AVZfdDN1WG.r/jHryU/QsO2p4I9t3HtUKCx.Sc0GGG",
"roleId": 2,
"createdAt": "2017-05-18T15:33:21.224Z",
"updatedAt": "2017-05-18T15:33:21.224Z"
}
},
{
"id": 1,
"title": "seed document test",
"docContent": "Voluptas dignissimos saepe et quia in amet eveniet. Incidunt dolorum minima occaecati aut consequatur ex odit. Fuga quidem necessitatibus aut architecto. Modi qui veniam dignissimos ut deserunt. Doloribus quisquam et voluptas consequatur reiciendis. Nam ut ea iste laudantium dolores iusto perferendis.",
"docType": null,
"viewAccess": "private",
"role": "1",
"createdAt": "2017-05-18T15:31:39.401Z",
"updatedAt": "2017-05-18T15:31:39.401Z",
"userId": 1,
"User": {
"id": 1,
"name": "administrator user",
"username": "admin",
"email": "[email protected]",
"password": "$2a$08$DsSJvQdzWp8iagIpgKfE7uf8BPWje80KAzqX2hgm0AwAXjM9A0xcC",
"roleId": 1,
"createdAt": "2017-05-18T15:31:39.064Z",
"updatedAt": "2017-06-02T18:23:26.445Z"
}
}
]
}</code></pre></li>
</ul>
<h6>GET HTTP Request</h6><ul>
<li><code>GET /documents/:id</code></li>
<li>Requires: Authentication<h6>HTTP response</h6></li>
<li>HTTP Status: <code>200: 0k</code></li>
<li>JSON data<pre class="prettyprint source lang-json"><code>{
"id": 3,
"title": "Hello Document Ngene",
"docContent": "<p>Ngene created this document</p>",
"docType": null,
"viewAccess": "private",
"role": "2",
"createdAt": "2017-05-18T15:34:26.700Z",
"updatedAt": "2017-05-18T15:34:44.111Z",
"userId": 4,
"User": {
"id": 4,
"name": "Anthony",
"username": "anthony",
"email": "[email protected]",
"password": "$2a$10$oGsHABwrr34AVZfdDN1WG.r/jHryU/QsO2p4I9t3HtUKCx.Sc0GGG",
"roleId": 2,
"createdAt": "2017-05-18T15:33:21.224Z",
"updatedAt": "2017-05-18T15:33:21.224Z"
}
}</code></pre><h4>Update Document</h4><h6>PUT HTTP Request</h6></li>
<li><code>PUT /documents/:id</code></li>
<li>Requires: Authentication<h6>HTTP response</h6></li>
<li>HTTP Status: <code>200: 0k</code></li>
<li>JSON data<pre class="prettyprint source lang-json"><code>{
"updatedDoc": {
"id": 3,
"title": "Hello Document Ngene - Modified",
"docContent": "<p>Ngene created this document</p>",
"docType": null,
"viewAccess": "private",
"role": "2",
"createdAt": "2017-05-18T15:34:26.700Z",
"updatedAt": "2017-06-05T12:05:29.738Z",
"userId": 4
},
"message": "Document updated successfully"
}</code></pre><h4>Delete Document</h4><h6>DELET HTTP Request</h6></li>
<li><code>DELET /documents/:id</code></li>
<li>Requires: Authentication<h6>HTTP response</h6></li>
<li>HTTP Status: <code>200: 0k</code></li>
<li>JSON data<pre class="prettyprint source lang-json"><code>{
"message": "test, was successfully deleted"
}</code></pre></li>
</ul>
<h4>Limitations</h4><p>Currently, we can't say our API can handle larger requests, this may be a problem when our user base grows to over million.</p></article>
</section>
</div>
</div>
<div class="clearfix"></div>
<div class="col-md-3">
<div id="toc" class="col-md-3 hidden-xs hidden-sm hidden-md"></div>
</div>
</div>
</div>
<div class="modal fade" id="searchResults">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button>
<h4 class="modal-title">Search results</h4>
</div>
<div class="modal-body"></div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
</div>
</div><!-- /.modal-content -->
</div><!-- /.modal-dialog -->
</div>
<footer>
<span class="copyright">
Anuoluwapo Onifade © 2017
</span>
<span class="jsdoc-message">
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.4.3</a>
on 2017-06-05T13:13:54+01:00
using the <a href="https://github.com/docstrap/docstrap">DocStrap template</a>.
</span>
</footer>
<script src="scripts/docstrap.lib.js"></script>
<script src="scripts/toc.js"></script>
<script type="text/javascript" src="scripts/fulltext-search-ui.js"></script>
<script>
$( function () {
$( "[id*='$']" ).each( function () {
var $this = $( this );
$this.attr( "id", $this.attr( "id" ).replace( "$", "__" ) );
} );
$( ".tutorial-section pre, .readme-section pre, pre.prettyprint.source" ).each( function () {
var $this = $( this );
var example = $this.find( "code" );
exampleText = example.html();
var lang = /{@lang (.*?)}/.exec( exampleText );
if ( lang && lang[1] ) {
exampleText = exampleText.replace( lang[0], "" );
example.html( exampleText );
lang = lang[1];
} else {
var langClassMatch = example.parent()[0].className.match(/lang\-(\S+)/);
lang = langClassMatch ? langClassMatch[1] : "javascript";
}
if ( lang ) {
$this
.addClass( "sunlight-highlight-" + lang )
.addClass( "linenums" )
.html( example.html() );
}
} );
Sunlight.highlightAll( {
lineNumbers : true,
showMenu : true,
enableDoclinks : true
} );
$.catchAnchorLinks( {
navbarOffset: 10
} );
$( "#toc" ).toc( {
anchorName : function ( i, heading, prefix ) {
return $( heading ).attr( "id" ) || ( prefix + i );
},
selectors : "#toc-content h1,#toc-content h2,#toc-content h3,#toc-content h4",
showAndHide : false,
smoothScrolling: true
} );
$( "#main span[id^='toc']" ).addClass( "toc-shim" );
$( '.dropdown-toggle' ).dropdown();
$( "table" ).each( function () {
var $this = $( this );
$this.addClass('table');
} );
} );
</script>
<!--Navigation and Symbol Display-->
<script>
$( function () {
$( '#main' ).localScroll( {
offset : { top : 60 } //offset by the height of your header (give or take a few px, see what works for you)
} );
$( "dt.name" ).each( function () {
var $this = $( this ).find("h4");
var icon = $( "<i/>" ).addClass( "icon-plus-sign" ).addClass( "pull-right" ).addClass( "icon-white" );
var dt = $(this);
var children = dt.next( "dd" );
dt.prepend( icon ).css( {cursor : "pointer"} );
dt.addClass( "member-collapsed" ).addClass( "member" );
children.hide();
dt.children().on( "click", function () {
children = dt.next( "dd" );
children.slideToggle( "fast", function () {
if ( children.is( ":visible" ) ) {
icon.addClass( "icon-minus-sign" ).removeClass( "icon-plus-sign" ).removeClass( "icon-white" );
dt.addClass( "member-open" ).animate( "member-collapsed" );
} else {
icon.addClass( "icon-plus-sign" ).removeClass( "icon-minus-sign" ).addClass( "icon-white" );
dt.addClass( "member-collapsed" ).removeClass( "member-open" );
}
} );
} );
} );
} );
</script>
<!--Google Analytics-->
<script type="text/javascript">
$(document).ready(function() {
SearcherDisplay.init();
});
</script>
</body>
</html>