-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpostman.json
1453 lines (1453 loc) · 67.2 KB
/
postman.json
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
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
{
"info": {
"_postman_id": "a0aa2d04-e5c1-4f34-8955-4125a370b7c4",
"name": "pp1_backend",
"description": "collection for testing the backend of scriptorium",
"schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json",
"_exporter_id": "27398578",
"_collection_link": "https://scriptoriumbackend.postman.co/workspace/11ff5cdb-3213-4c92-a54a-003e8fb535fd/collection/27398578-a0aa2d04-e5c1-4f34-8955-4125a370b7c4?action=share&source=collection_link&creator=27398578"
},
"item": [
{
"name": "user",
"item": [
{
"name": "signup",
"event": [
{
"listen": "test",
"script": {
"exec": [
""
],
"type": "text/javascript",
"packages": {}
}
}
],
"request": {
"method": "POST",
"header": [
{
"key": "Content-Type",
"value": "application/json",
"type": "text"
}
],
"body": {
"mode": "raw",
"raw": "{\n \"userName\": \"user2\",\n \"firstName\": \"fname\",\n \"lastName\": \"lastname\",\n \"avatar\": \"www.icon.com\",\n \"email\": \"[email protected]\",\n \"password\": \"johndoe123\",\n \"role\": \"USER\", // USER or ADMIN\n \"phoneNumber\": \"1111111112\"\n}",
"options": {
"raw": {
"language": "json"
}
}
},
"url": {
"raw": "http://localhost:3000/api/users/signup",
"protocol": "http",
"host": [
"localhost"
],
"port": "3000",
"path": [
"api",
"users",
"signup"
]
},
"description": "### API Request Description\n\nThis endpoint allows users to sign up by providing their user details including username, first name, last name, avatar URL, email, password, role, and phone number.\n\n- `userName` (string): The username of the user.\n \n- `firstName` (string): The first name of the user.\n \n- `lastName` (string): The last name of the user.\n \n- `avatar` (string): The URL of the user's avatar.\n \n- `email` (string): The email address of the user.\n \n- `password` (string): The password for the user account.\n \n- `role` (string): The role of the user (e.g., USER, ADMIN).\n \n- `phoneNumber` (string): The phone number of the user.\n \n\n### API Response\n\nThe response of this request is in JSON format and includes the following schema:\n\n``` json\n{\n \"user\": {\n \"id\": 0,\n \"firstName\": \"\",\n \"lastName\": \"\",\n \"userName\": \"\",\n \"email\": \"\",\n \"phoneNumber\": \"\",\n \"role\": \"\"\n }\n}\n\n ```\n\nThe `user` object in the response contains the user details with the following fields:\n\n- `id` (number): The unique identifier of the user.\n \n- `firstName` (string): The first name of the user.\n \n- `lastName` (string): The last name of the user.\n \n- `userName` (string): The username of the user.\n \n- `email` (string): The email address of the user.\n \n- `phoneNumber` (string): The phone number of the user.\n \n- `role` (string): The role of the user."
},
"response": []
},
{
"name": "login",
"event": [
{
"listen": "test",
"script": {
"exec": [
"",
"var jsonData = pm.response.json();",
"pm.collectionVariables.set(\"accessToken\", jsonData.accessToken);",
"// Save the token as an environment variable",
"pm.environment.set(\"accessToken\", jsonData.accessToken);",
""
],
"type": "text/javascript",
"packages": {}
}
}
],
"request": {
"method": "POST",
"header": [
{
"key": "Content-Type",
"value": "application/json",
"type": "text"
}
],
"body": {
"mode": "raw",
"raw": "{\n \"userName\": \"user2\",\n \"password\": \"johndoe123\"\n}",
"options": {
"raw": {
"language": "json"
}
}
},
"url": {
"raw": "http://localhost:3000/api/users/login",
"protocol": "http",
"host": [
"localhost"
],
"port": "3000",
"path": [
"api",
"users",
"login"
]
},
"description": "The `POST /api/users/login` endpoint is used to authenticate a user and obtain access and refresh tokens.\n\nLogin is needed to perform USER and ADMIN level actions in the application.\n\n### Request Body\n\n- `userName` (string): The username of the user.\n \n- `password` (string): The password of the user.\n \n\n### Response\n\nThe response for this request is a JSON object with the following schema:\n\n``` json\n{\n \"accessToken\": {\n \"type\": \"string\"\n },\n \"refreshToken\": {\n \"type\": \"string\"\n}\n\n ```"
},
"response": []
},
{
"name": "get-profile-of-user",
"event": [
{
"listen": "prerequest",
"script": {
"exec": [
"pm.globals.set()"
],
"type": "text/javascript",
"packages": {}
}
}
],
"request": {
"auth": {
"type": "bearer",
"bearer": [
{
"key": "token",
"value": "{{accessToken}}",
"type": "string"
}
]
},
"method": "GET",
"header": [
{
"key": "Content-Type",
"value": "application/json",
"type": "text"
}
],
"url": {
"raw": "http://localhost:3000/api/users/3",
"protocol": "http",
"host": [
"localhost"
],
"port": "3000",
"path": [
"api",
"users",
"3"
]
},
"description": "The endpoint retrieves user data for a single user. Please pass in the id of the user in the url (api/users/{id}).\n\nUsers cannot see hidden posts here, even if the user who the user is serching is the same as the user logged in.\n\nThe response returned is in JSON format and has the following schema:\n\n``` json\n{\n \"type\": \"object\",\n \"properties\": {\n \"id\": {\n \"type\": \"number\"\n },\n \"firstName\": {\n \"type\": \"string\"\n },\n \"lastName\": {\n \"type\": \"string\"\n },\n \"userName\": {\n \"type\": \"string\"\n },\n \"avatar\": {\n \"type\": \"string\"\n },\n \"email\": {\n \"type\": \"string\"\n },\n \"phoneNumber\": {\n \"type\": \"string\"\n },\n \"password\": {\n \"type\": \"string\"\n },\n \"role\": {\n \"type\": \"string\"\n },\n \"blogPosts\": {\n \"type\": \"array\"\n },\n \"savedTemplates\": {\n \"type\": \"array\"\n }\n }\n}\n\n ```"
},
"response": []
},
{
"name": "edit-profile-of-user",
"request": {
"auth": {
"type": "bearer",
"bearer": [
{
"key": "token",
"value": "{{accessToken}}",
"type": "string"
}
]
},
"method": "POST",
"header": [],
"body": {
"mode": "raw",
"raw": "{\n \"firstName\": \"whatever\",\n \"lastName\": \"whatevr\",\n \"userName\": null,\n \"phoneNumber\": \"0000000110\",\n \"avatar\": \"www.newicon.com\",\n \"role\": \"ADMIN\",\n \"password\": null,\n \"email\": null\n}",
"options": {
"raw": {
"language": "json"
}
}
},
"url": {
"raw": "http://localhost:3000/api/users/3",
"protocol": "http",
"host": [
"localhost"
],
"port": "3000",
"path": [
"api",
"users",
"3"
]
},
"description": "The endpoint allows users to perform editing of a user's profile who owns this account by passing in a user id in the request quary parameter, and the data to send in the request body. The allowed methods are POST and GET. The payload should include the user's details such as name, email, and role. An example request and response will be added to illustrate the usage of this endpoint.\n\n### Example Request\n\n``` json\n{\n \"firstName\": \"whatever\",\n \"lastName\": \"whatevr\",\n \"userName\": null,\n \"phoneNumber\": \"0000000110\",\n \"avatar\": \"www.newicon.com\",\n \"role\": null,\n \"password\": null,\n \"email\": null\n}\n\n ```\n\n### Example Response\n\n- Status: 200\n \n- {\"message\": \"\",\"updatedProfile\": { \"id\": 0, \"firstName\": \"\", \"lastName\": \"\", \"userName\": \"\", \"avatar\": \"\", \"email\": \"\", \"phoneNumber\": \"\", \"password\": \"\", \"role\": \"\"}}\n \n\n### Payload\n\nThe request should have a raw body with the following parameters:\n\n- firstName (text): The first name of the user.\n \n- lastName (text): The last name of the user.\n \n- phoneNumber (text): The phone number of the user.\n \n- avatar (text): The URL of the user's avatar image.\n \n- role (text, optional):\n \n\n### Example\n\n``` json\n{\n \"firstName\": \"whatever\",\n \"lastName\": \"whatevr\",\n \"phoneNumber\": \"0000000110\",\n \"avatar\": \"www.newicon.com\"\n}\n\n ```\n\n### Response\n\nUpon successful execution, the endpoint returns a JSON object with a status code of 200 and the following structure:\n\n``` json\n{\n \"message\": \"\",\n \"updatedProfile\": {\n \"id\": 0,\n \"firstName\": \"\",\n \"lastName\": \"\",\n \"userName\": \"\",\n \"avatar\": \"\",\n \"email\": \"\",\n \"phoneNumber\": \"\",\n \"password\": \"\",\n \"role\": \"\"\n }\n}\n\n ```\n\nThe request body should contain the user's details such as first name, last name, phone number, avatar URL, role, username, password, and email.\n\nThe parameters for this endpoint include the ID of the user in the URL path and the user details in the request body. The user details are optional, and only the fields that need to be updated or created should be included in the request body.\n\nThis endpoint allows you to update your user information.\n\n#### Request Body\n\n- `firstName` (text, optional): The first name of the user.\n \n- `lastName` (text, optional): The last name of the user.\n \n- `phoneNumber` (text, optional): The phone number of the user.\n \n- `avatar` (text, optional): The URL of the user's avatar image.\n \n- `role` (text, optional): The role of the user.\n \n- `userName` (text, optional): The username of the user.\n \n- `password` (text, optional): The password of the user.\n \n- `email` (text, optional): The email address of the user.\n \n\n#### Response\n\nThe response is in JSON format with the following schema:\n\n``` json\n{\n \"firstName\": \"\"\n}\n\n ```"
},
"response": []
},
{
"name": "refresh",
"event": [
{
"listen": "test",
"script": {
"exec": [
"var jsonData = pm.response.json();",
"// Save the token as an environment variable",
"pm.collectionVariables.set(\"accessToken\", jsonData.accessToken);",
"pm.environment.set(\"accessToken\", jsonData.accessToken);",
""
],
"type": "text/javascript",
"packages": {}
}
}
],
"request": {
"auth": {
"type": "bearer",
"bearer": [
{
"key": "token",
"value": "{{accessToken}}",
"type": "string"
}
]
},
"method": "POST",
"header": [
{
"key": "Content-Type",
"value": "application/json",
"type": "text"
}
],
"body": {
"mode": "raw",
"raw": "{\n \"refreshToken\": \"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6NCwidXNlck5hbWUiOiJ1c2VyMSIsImVtYWlsIjoidXNlcjFAZXhhbXBsZS5jb20iLCJyb2xlIjoiVVNFUiIsImlhdCI6MTczMDU5Mjc4NiwiZXhwIjoxNzMwNjc5MTg2fQ.LpC-5DxoNIm-cuNz5fAJ7VxkhUDVMNoVlXvjfEmEFYc\"\n\n}",
"options": {
"raw": {
"language": "json"
}
}
},
"url": {
"raw": "http://localhost:3000/api/users/refresh",
"protocol": "http",
"host": [
"localhost"
],
"port": "3000",
"path": [
"api",
"users",
"refresh"
]
},
"description": "### Refresh User Access Token\n\nThis endpoint is used to refresh the user's access token by providing the refresh token.\n\n**Request Body**\n\n- refreshToken (string, required): The refresh token used to generate a new access token.\n \n\nExample:\n\n``` json\n{\n \"refreshToken\": \"eyJhbGciOiJIUzI1NiIsInR5cCI6Ik ...\"\n}\n\n ```\n\n**Response** \nThe response is in JSON format and includes the new access token.\n\nExample:\n\n``` json\n{\n \"accessToken\": \"\"\n}\n\n ```"
},
"response": []
}
],
"description": "user endpoints\n\n- login\n \n- signup\n \n- edit profile of a user\n \n- get the profile of a specific user\n \n- refresh access token"
},
{
"name": "blog",
"item": [
{
"name": "create a blog",
"request": {
"auth": {
"type": "bearer",
"bearer": [
{
"key": "token",
"value": "{{accessToken}}",
"type": "string"
}
]
},
"method": "POST",
"header": [
{
"key": "Content-Type",
"value": "application/json",
"type": "text"
}
],
"body": {
"mode": "raw",
"raw": "{\n \"description\": \"blog 6 description\",\n \"tags\": \"arrays, hashmaps\",\n \"title\": \"blog 6\",\n \"templateIds\": [3, 2] // add these template with given id's to this blog, could be null also\n}",
"options": {
"raw": {
"language": "json"
}
}
},
"url": {
"raw": "http://localhost:3000/api/blogs",
"protocol": "http",
"host": [
"localhost"
],
"port": "3000",
"path": [
"api",
"blogs"
]
},
"description": "This endpoint allows you to create a new blog by sending an HTTP POST request to the specified URL. The request should include a JSON payload in the raw request body with the following parameters:\n\n- `description` (string): The description of the blog.\n \n- `tags` (string): Tags associated with the blog.\n \n- `title` (string): The title of the blog.\n \n- `templateIds` (array): IDs of templates related to the blog.\n \n\nUpon successful creation, the response will include the details of the newly created blog."
},
"response": []
},
{
"name": "get list of blogs",
"request": {
"auth": {
"type": "bearer",
"bearer": [
{
"key": "token",
"value": "{{accessToken}}",
"type": "string"
}
]
},
"method": "GET",
"header": [],
"url": {
"raw": "http://localhost:3000/api/blogs?tags&description&title&templateTitle",
"protocol": "http",
"host": [
"localhost"
],
"port": "3000",
"path": [
"api",
"blogs"
],
"query": [
{
"key": "tags",
"value": null
},
{
"key": "description",
"value": null
},
{
"key": "title",
"value": null
},
{
"key": "templateTitle",
"value": null
}
]
},
"description": "# Get Blogs\n\nThis endpoint retrieves a list of blogs based on the provided query parameters. Its going to return blogs based on filtering by the query parameters, ordered by upvotes.\n\n## Request\n\n### Query Parameters\n\n- `tags` (optional): Filter blogs by tags.\n \n- `description` (optional): Filter blogs by description.\n \n- `title` (optional): Filter blogs by title.\n \n- `templateTitle` (optional): Filter blogs by template title.\n \n\nReturn ordered by upvotes.\n\n## Response\n\nThe response for this request is a JSON object representing the list of blogs ordered by highest upvotes. The schema for the response can be described as follows:\n\n``` json\n{\n \"type\": \"object\",\n \"properties\": {\n \"blogs\": {\n \"type\": \"array\",\n \"items\": {\n \"type\": \"object\",\n \"properties\": {\n \"id\": {\n \"type\": \"string\"\n },\n \"title\": {\n \"type\": \"string\"\n },\n \"description\": {\n \"type\": \"string\"\n },\n \"tags\": {\n \"type\": \"array\",\n \"items\": {\n \"type\": \"string\"\n }\n }\n }\n }\n }\n }\n}\n\n ```"
},
"response": []
},
{
"name": "rate a blog",
"request": {
"auth": {
"type": "bearer",
"bearer": [
{
"key": "token",
"value": "{{accessToken}}",
"type": "string"
}
]
},
"method": "POST",
"header": [
{
"key": "Content-Type",
"value": "application/json",
"type": "text"
}
],
"body": {
"mode": "raw",
"raw": "{\n \"voteType\": \"\" // \"upvote\" or \"downvote\"\n}",
"options": {
"raw": {
"language": "json"
}
}
},
"url": {
"raw": "http://localhost:3000/api/blogs/1/rate",
"protocol": "http",
"host": [
"localhost"
],
"port": "3000",
"path": [
"api",
"blogs",
"1",
"rate"
]
},
"description": "### Rate Blog\n\nThis endpoint allows the user to rate a specific blog by providing an upvote or downvote.\n\n#### Request Body\n\n- `voteType` (string, required): The type of vote, which can be either \"upvote\" or \"downvote\".\n \n\n#### Response\n\nThe response will be in JSON format and includes the following schema:\n\n``` json\n{\n \"voteType\": \"\" //upvote or downvote\n}\n\n ```\n\nThe last execution returned a status of 200 with the following response body:\n\n``` json\n{\n \"message\": \"string\",\n \"updatedBlogPost\": {\n \"id\": \"number\",\n \"authorId\": \"number\",\n \"title\": \"string\",\n \"description\": \"string\",\n \"upvote\": \"number\",\n \"downvote\": \"number\",\n \"createdAt\": \"string\",\n \"updatedAt\": \"string\",\n \"tags\": \"string\",\n \"hidden\": \"boolean\"\n }\n}\n\n ```\n\nThis endpoint allows the user to rate a specific blog by providing an upvote or downvote."
},
"response": []
},
{
"name": "hide a blog",
"request": {
"auth": {
"type": "bearer",
"bearer": [
{
"key": "token",
"value": "{{accessToken}}",
"type": "string"
}
]
},
"method": "POST",
"header": [
{
"key": "Content-Type",
"value": "application/json",
"type": "text"
}
],
"body": {
"mode": "raw",
"raw": "",
"options": {
"raw": {
"language": "json"
}
}
},
"url": {
"raw": "http://localhost:3000/api/blogs/7/hide",
"protocol": "http",
"host": [
"localhost"
],
"port": "3000",
"path": [
"api",
"blogs",
"7",
"hide"
]
},
"description": "# Hide Blog Endpoint\n\nThis endpoint allows an admin to hide a specific blog with the given ID. Hiding a blog will mark its attribute \"hidden\" to true, and now users won't be able to see it in get requests anymore (you can try this my providing the same blog id in the next request and seeing it will not show).\n\nThis url accepts a blog id to hide. (api/blogs/{id}/hide)\n\n## Request\n\n- Method: POST\n \n- URL: `http://localhost:3000/api/blogs/{id}/hide`\n \n\n## Response\n\nThe response for this request will be a JSON schema with the following properties:\n\n- `message` (string) - Provides a message regarding the operation.\n \n\nExample Response:\n\n``` json\n{\n \"message\": \"Blog with ID 1 has been successfully hidden.\"\n \"hiddenPost\": {\n \"id\": 1,\n \"authorId\": 1,\n \"title\": \"blog 1\",\n \"description\": \"blog 1 description\",\n \"upvote\": 1,\n \"downvote\": 1,\n \"createdAt\": \"2024-11-03T06:07:00.281Z\",\n \"updatedAt\": \"2024-11-03T06:18:55.832Z\",\n \"tags\": \"arrays, hashmaps\",\n \"hidden\": true\n },\n \"closedReports\": {\n \"count\": 0\n }\n}\n\n ```"
},
"response": []
},
{
"name": "get a blog",
"event": [
{
"listen": "test",
"script": {
"exec": [
"",
""
],
"type": "text/javascript",
"packages": {}
}
}
],
"request": {
"auth": {
"type": "bearer",
"bearer": [
{
"key": "token",
"value": "{{accessToken}}",
"type": "string"
}
]
},
"method": "GET",
"header": [
{
"key": "Content-Type",
"value": "application/json",
"type": "text"
}
],
"url": {
"raw": "http://localhost:3000/api/blogs/2",
"protocol": "http",
"host": [
"localhost"
],
"port": "3000",
"path": [
"api",
"blogs",
"2"
]
},
"description": "# Blog Details\n\nThis endpoint retrieves the details of a specific blog.\n\n(api/blogs/{id}).\n\n## Method\n\nGET\n\n## Payload\n\nThis endpoint does not require a request payload.\n\n## Example\n\n### Request\n\n```\nGET http://localhost:3000/api/blogs/2\n\n ```\n\n### Response\n\n``` json\n{\n \"id\": 0,\n \"authorId\": 0,\n \"title\": \"\",\n \"description\": \"\",\n \"upvote\": 0,\n \"downvote\": 0,\n \"createdAt\": \"\",\n \"updatedAt\": \"\",\n \"tags\": \"\",\n \"hidden\": true,\n \"author\": {\n \"id\": 0,\n \"firstName\": \"\",\n \"lastName\": \"\",\n \"userName\": \"\",\n \"avatar\": \"\",\n \"email\": \"\",\n \"phoneNumber\": \"\",\n \"password\": \"\",\n \"role\": \"\"\n },\n \"comments\": [],\n \"templates\": []\n}\n\n ```\n\nThis endpoint retrieves a specific blog with the ID passed into the request parameter.\n\n#### Response\n\nThe response will be in JSON format with an array of blog data. Here is a sample JSON schema for the response:\n\n``` json\n[]\n\n ```"
},
"response": []
},
{
"name": "edit a blog",
"request": {
"auth": {
"type": "bearer",
"bearer": [
{
"key": "token",
"value": "{{accessToken}}",
"type": "string"
}
]
},
"method": "POST",
"header": [
{
"key": "Content-Type",
"value": "application/json",
"type": "text"
}
],
"body": {
"mode": "raw",
"raw": "{\n \"title\": \"blog 10 title change\",\n \"description\": \"blog 10 title CHANGE\",\n \"tags\": \"arrays, hashmaps\",\n \"templateIdsToAdd\": [6], // example template id to add to this blog\n \"templateIdsToRemove\": [4]// example template id to remove from thsi blog\n}",
"options": {
"raw": {
"language": "json"
}
}
},
"url": {
"raw": "http://localhost:3000/api/blogs/6",
"protocol": "http",
"host": [
"localhost"
],
"port": "3000",
"path": [
"api",
"blogs",
"6"
]
},
"description": "### Request Description\n\nThis endpoint is used to update a specific blog with the given ID in the query parameter. The request should be sent as an HTTP POST to the specified URL with the blog ID in the endpoint. The request body should contain the updated title, description, tags, templatesIdsToAdd, and templatesIdsToRemove.\n\nIf the blog is flagged (marked as hidden: true), then no one can edit this blog.\n\n#### Request Body (all fields are optional)\n\n- title (string): The updated title of the blog.\n \n- description (string): The updated description of the blog.\n \n- tags (string): The updated tags for the blog.\n \n- templatesIdsToAdd (array): IDs of templates to be added to the blog.\n \n- templatesIdsToRemove (array): IDs of templates to be removed from the blog.\n \n\n### Response\n\nThe response will be in JSON format with the following schema:\n\n``` json\n{\n \"id\": 0,\n \"authorId\": 0,\n \"title\": \"\",\n \"description\": \"\",\n \"upvote\": 0,\n \"downvote\": 0,\n \"createdAt\": \"\",\n \"updatedAt\": \"\",\n \"tags\": \"\",\n \"hidden\": true,\n \"author\": {\n \"id\": 0,\n \"firstName\": \"\",\n \"lastName\": \"\",\n \"userName\": \"\",\n \"avatar\": \"\",\n \"email\": \"\",\n \"phoneNumber\": \"\",\n \"password\": \"\",\n \"role\": \"\"\n },\n \"templates\": []\n}\n\n ```\n\nThe response will include the updated blog details, including the ID, author information, title, description, upvote count, downvote count, creation and update timestamps, tags, and hidden status."
},
"response": []
},
{
"name": "delete a blog",
"request": {
"auth": {
"type": "bearer",
"bearer": [
{
"key": "token",
"value": "{{accessToken}}",
"type": "string"
}
]
},
"method": "DELETE",
"header": [],
"url": {
"raw": "http://localhost:3000/api/blogs/5",
"protocol": "http",
"host": [
"localhost"
],
"port": "3000",
"path": [
"api",
"blogs",
"5"
]
},
"description": "### DELETE /api/blogs/2\n\nThis endpoint is used to delete a specific blog with the ID of {id} at the end of the endpoint (api/blogs/{id}) inly if the user is the author of that blog.\n\n#### Request\n\nNo request body is required for this request.\n\n#### Response\n\nThe response for this request is a JSON object with the following schema:\n\n``` json\n{\n \"type\": \"object\",\n \"properties\": {\n \"message\": {\n \"type\": \"string\"\n }\n }\n}\n\n ```\n\nThe response contains a status code of 200 and a JSON object with a \"message\" key, which provides information about the success of the deletion operation."
},
"response": []
},
{
"name": "view hidden blogs of logged in user",
"request": {
"auth": {
"type": "bearer",
"bearer": [
{
"key": "token",
"value": "{{accessToken}}",
"type": "string"
}
]
},
"method": "GET",
"header": [
{
"key": "Content-Type",
"value": "application/json",
"type": "text"
}
],
"url": {
"raw": "http://localhost:3000/api/blogs/view-hidden",
"protocol": "http",
"host": [
"localhost"
],
"port": "3000",
"path": [
"api",
"blogs",
"view-hidden"
]
},
"description": "This endpoint makes an HTTP GET request to retrieve hidden blog posts of this user that are flagged. The response will be in JSON format and will include an array of blog posts with their respective details. Below is the JSON schema for the response.\n\nOnly posts hidden for the current logged in user will be seen here, thus fulfilling the fact that other users won't be able to see hidden posts, but only the authors will, and they wont be able to edit them.\n\n``` json\n[\n {\n \"id\": \"number\",\n \"authorId\": \"number\",\n \"title\": \"string\",\n \"description\": \"string\",\n \"upvote\": \"number\",\n \"downvote\": \"number\",\n \"createdAt\": \"string\",\n \"updatedAt\": \"string\",\n \"tags\": \"string\",\n \"hidden\": \"boolean\"\n }\n]\n\n ```\n\nThe response will include the blog post details such as ID, author ID, title, description, upvotes, downvotes, creation and update timestamps, tags, and a boolean flag indicating if the post is hidden.\n\nNo request body is required for this GET request."
},
"response": []
},
{
"name": "report a blog",
"request": {
"auth": {
"type": "bearer",
"bearer": [
{
"key": "token",
"value": "{{accessToken}}",
"type": "string"
}
]
},
"method": "POST",
"header": [],
"body": {
"mode": "raw",
"raw": "{\n \"description\": \"this blog is mean to me\",\n \"blogId\": 7\n\n}",
"options": {
"raw": {
"language": "json"
}
}
},
"url": {
"raw": "http://localhost:3000/api/report",
"protocol": "http",
"host": [
"localhost"
],
"port": "3000",
"path": [
"api",
"report"
]
},
"description": "### POST /api/report\n\nThis endpoint is used to report a blog.\n\n#### Request Body\n\n- `description` (string) - The description of the report.\n \n- `blogId` (number) - The ID of the blog being reported.\n \n\n#### Response\n\nThe response will be in JSON format with the following schema:\n\n``` json\n{\n \"report\": {\n \"id\": 0,\n \"status\": \"OPEN\",\n \"authorId\": 0,\n \"description\": \"\",\n \"createdAt\": \"\",\n \"blogId\": 0,\n \"commentId\": null\n }\n}\n\n ```\n\nThe `report` object contains the details of the reported blog, including its ID, status, author ID, description, creation timestamp, blog ID, and associated comment ID (if any)."
},
"response": []
}
]
},
{
"name": "templates",
"item": [
{
"name": "get list of templates",
"protocolProfileBehavior": {
"disableBodyPruning": true
},
"request": {
"method": "GET",
"header": [
{
"key": "",
"value": "",
"type": "text"
}
],
"body": {
"mode": "raw",
"raw": "",
"options": {
"raw": {
"language": "json"
}
}
},
"url": {
"raw": "http://localhost:3000/api/template",
"protocol": "http",
"host": [
"localhost"
],
"port": "3000",
"path": [
"api",
"template"
],
"query": [
{
"key": "",
"value": null,
"disabled": true
}
]
},
"description": "### GET /api/template\n\nThis endpoint retrieves a list of templates.\n\n#### Request\n\nThis is a GET request to fetch the list of templates.\n\n#### Response\n\nThe response will be in JSON format and will have the following schema:\n\n``` json\n{\n \"templates\": [\n {\n \"id\": \"number\",\n \"ownerId\": \"number\",\n \"title\": \"string\",\n \"explanation\": \"string\",\n \"codeId\": \"number\",\n \"isForked\": \"boolean\",\n \"parentTemplateId\": \"number or null\",\n \"createdAt\": \"string\",\n \"updatedAt\": \"string\",\n \"tags\": \"string\"\n }\n ],\n \"currentPage\": \"number\",\n \"pageSize\": \"number\"\n}\n\n ```"
},
"response": []
},
{
"name": "create a template",
"request": {
"auth": {
"type": "bearer",
"bearer": [
{
"key": "token",
"value": "{{accessToken}}",
"type": "string"
}
]
},
"method": "POST",
"header": [],
"body": {
"mode": "raw",
"raw": "{\n \"title\": \"Java Calculator Template\",\n \"explanation\": \"A simple calculator that performs basic arithmetic operations.\",\n \"tags\": \"Java, Calculator\",\n \"code\": \"import java.util.Scanner;\\n\\npublic class Calculator {\\n public static void main(String[] args) {\\n Scanner scanner = new Scanner(System.in);\\n double num1 = scanner.nextDouble();\\n double num2 = scanner.nextDouble();\\n char operator = scanner.next().charAt(0);\\n double result;\\n\\n switch (operator) {\\n case '+':\\n result = num1 + num2;\\n break;\\n case '-':\\n result = num1 - num2;\\n break;\\n case '*':\\n result = num1 * num2;\\n break;\\n case '/':\\n if (num2 != 0) {\\n result = num1 / num2;\\n } else {\\n System.out.println(\\\"Cannot divide by zero\\\");\\n return;\\n }\\n break;\\n default:\\n System.out.println(\\\"Invalid operator\\\");\\n return;\\n }\\n\\n System.out.printf(\\\"Result: %.2f\\\", result);\\n }\\n}\",\n \"language\": \"java\",\n \"input\": \"5.0\\n3.0\\n+\\n\"\n}\n",
"options": {
"raw": {
"language": "json"
}
}
},
"url": {
"raw": "http://localhost:3000/api/template/create",
"protocol": "http",
"host": [
"localhost"
],
"port": "3000",
"path": [
"api",
"template",
"create"
]
},
"description": "### Create Template\n\nThis endpoint allows the user to create a new template by providing the title, explanation, tags, code, and language.\n\n#### Request Body\n\n- title (string, required): The title of the new template.\n \n- explanation (string, required): A brief explanation of the new template.\n \n- tags (string, required): Tags associated with the new template.\n \n- code (string, required): The code content of the new template.\n \n- language (string, required): The programming language of the code.\n \n\n#### Response\n\nThe response will be in JSON format with the following schema:\n\n``` json\n{\n \"type\": \"object\",\n \"properties\": {\n \"template\": {\n \"type\": \"object\",\n \"properties\": {\n \"id\": { \"type\": \"integer\" },\n \"ownerId\": { \"type\": \"integer\" },\n \"title\": { \"type\": \"string\" },\n \"explanation\": { \"type\": \"string\" },\n \"codeId\": { \"type\": \"null\" },\n \"isForked\": { \"type\": \"boolean\" },\n \"parentTemplateId\": { \"type\": \"null\" },\n \"createdAt\": { \"type\": \"string\" },\n \"updatedAt\": { \"type\": \"string\" },\n \"tags\": { \"type\": \"string\" }\n }\n },\n \"message\": { \"type\": \"string\" }\n }\n}\n\n ```"
},
"response": []
},
{
"name": "fork a template as a user",
"request": {
"auth": {
"type": "bearer",
"bearer": [
{
"key": "token",
"value": "{{accessToken}}",
"type": "string"
}
]
},
"method": "POST",
"header": [],
"body": {
"mode": "raw",
"raw": "{\n \"title\": \"this is my forked template\",\n \"explanation\": \"trying out new stuff from forked\",\n \"tags\": \"coooool\",\n \"code\": \"print('hi')\",\n \"language\": \"python\",\n \"parentTemplateId\": 1\n}",
"options": {
"raw": {
"language": "json"
}
}
},
"url": {
"raw": "http://localhost:3000/api/template/create",
"protocol": "http",
"host": [
"localhost"
],
"port": "3000",
"path": [
"api",
"template",
"create"
]
},
"description": "### Create Template\n\nThis endpoint allows the user to create a new template by providing the necessary details.\n\n**Request Body**\n\n- title (text, required): The title of the template.\n \n- explanation (text, required): A brief explanation of the template.\n \n- tags (text, required): Tags associated with the template.\n \n- code (text, required): The code content of the template.\n \n- language (text, required): The programming language of the template.\n \n- parentTemplateId (integer, required): The ID of the parent template if this template is a forked version.\n \n\n**Response**\n\n- Status: 201\n \n- Content-Type: application/json\n \n- template (object): Details of the created template including ID, owner ID, title, explanation, code ID, forked status, parent template ID, creation and update timestamps, and tags.\n \n- message (string): Any additional message related to the response."
},
"response": []
},
{
"name": "delete a template",
"request": {
"auth": {
"type": "bearer",
"bearer": [
{
"key": "token",
"value": "{{accessToken}}",
"type": "string"
}
]
},
"method": "DELETE",
"header": [],
"body": {
"mode": "raw",
"raw": "",
"options": {
"raw": {
"language": "json"
}
}
},
"url": {
"raw": "http://localhost:3000/api/template/delete/4 ",
"protocol": "http",
"host": [
"localhost"
],
"port": "3000",
"path": [
"api",
"template",
"delete",
"4 "
]
},
"description": "The API endpoint sends an HTTP DELETE request to [http://localhost:3000/api/template/delete/4](http://localhost:3000/api/template/delete/4) to delete a specific template. Upon successful execution, the response will have a status code of 200 and a content type of application/json. The response body will be a JSON object with a \"msg\" key, which may contain a message or be empty.\n\n**Query Parameters**\n\n- \\[id\\] -> refers to the id of the template of which the user/admin wants to delete (template/delete/\\[id\\])\n \n\n``` json\n{\n \"type\": \"object\",\n \"properties\": {\n \"msg\": {\n \"type\": \"string\"\n }\n }\n}\n\n ```"
},
"response": []
},
{
"name": "edit template",
"request": {
"auth": {
"type": "bearer",
"bearer": [
{
"key": "token",
"value": "{{accessToken}}",
"type": "string"
}
]
},
"method": "PUT",
"header": [],
"body": {
"mode": "raw",
"raw": "{\n \"title\": \"new title2\",\n \"explanation\": \"new explanation\",\n \"input\": \"5.0 4.0 -\"\n}",
"options": {
"raw": {
"language": "json"
}
}
},
"url": {
"raw": "http://localhost:3000/api/template/edit/7",
"protocol": "http",
"host": [
"localhost"
],
"port": "3000",
"path": [
"api",
"template",
"edit",
"7"
]
},
"description": "### Update Template\n\nThis endpoint is used to update a specific template with the provided ID.\n\n#### Request\n\n- Method: PUT\n \n- Endpoint: `http://localhost:3000/api/template/edit/7`\n \n- { \"title\": \"Lribbonacci\"}\n \n\n#### **Query Parameters**\n\n- \\[id\\] -> refers to the id of the template of which the user/admin wants to make some edits to (template/edit/\\[id\\])\n \n\n#### Response\n\nThe response is in JSON format and has the following schema:\n\n``` json\n{\n \"type\": \"object\",\n \"properties\": {\n \"id\": {\n \"type\": \"integer\"\n },\n \"ownerId\": {\n \"type\": \"integer\"\n },\n \"title\": {\n \"type\": \"string\"\n },\n \"explanation\": {\n \"type\": \"string\"\n },\n \"codeId\": {\n \"type\": \"integer\"\n },\n \"isForked\": {\n \"type\": \"boolean\"\n },\n \"parentTemplateId\": {\n \"type\": [\"integer\", \"null\"]\n },\n \"createdAt\": {\n \"type\": \"string\"\n },\n \"updatedAt\": {\n \"type\": \"string\"\n },\n \"tags\": {\n \"type\": \"string\"\n }\n }\n}\n\n ```"
},
"response": []
}
],
"description": "note that only authenticated users/admin can have access to creating, editing, deleting (their own) templates. Visitors can only view and use an already exisitng code template"
},
{
"name": "code",
"item": [
{
"name": "execute code",
"request": {
"auth": {
"type": "bearer",
"bearer": [
{
"key": "token",
"value": "{{accessToken}}",
"type": "string"
}
]
},
"method": "POST",
"header": [
{
"key": "Content-Type",
"value": "application/json",
"type": "text"
}
],
"body": {
"mode": "raw",
"raw": "{\r\n \"code\": \"def factorial(n): return 1 if n == 0 else n * factorial(n - 1)\\nnum = int(input())\\nprint(factorial(num))\",\r\n \"language\": \"python\",\r\n \"stdin\": \"\"\r\n}\r\n",
"options": {
"raw": {
"language": "json"
}
}
},
"url": {
"raw": "http://localhost:3000/api/code/execute",
"protocol": "http",
"host": [
"localhost"
],
"port": "3000",
"path": [
"api",
"code",
"execute"
]
},
"description": "The endpoint allows you to execute the provided code in the specified programming language. The request should include the code to be executed, the programming language, and the standard input if required.\n\n### Request Body\n\n- `code` (text): The code to be executed.\n \n- `language` (text): The programming language of the code.\n \n- `stdin` (text): The standard input for the code execution.\n \n\n### Response\n\nThe response is a JSON object with the following schema:\n\n``` json\n{\n \"type\": \"object\",\n \"properties\": {\n \"status\": {\n \"type\": \"string\"\n },\n \"output\": {\n \"type\": \"string\"\n }\n }\n}\n\n ```"
},
"response": []
}
]
},
{
"name": "comments",
"item": [
{
"name": "create a comment",
"request": {
"auth": {
"type": "bearer",
"bearer": [
{
"key": "token",
"value": "{{accessToken}}",
"type": "string"
}
]
},
"method": "POST",
"header": [],
"body": {
"mode": "raw",
"raw": "{\n \"content\": \"gross!!!!\"\n}",
"options": {
"raw": {
"language": "json"
}
}
},
"url": {
"raw": "http://localhost:3000/api/blogs/1/comments",
"protocol": "http",
"host": [
"localhost"
],
"port": "3000",
"path": [
"api",
"blogs",
"1",
"comments"
]
},
"description": "### Create a Comment on a Blog\n\nThis endpoint allows the user to create a new comment on a specific blog. Note that Blog ID is a query parameter as we are passing in the blog id of the blog of which we want to write a comment for.\n\n**Query Parameters**\n\n- blogs\\[id\\] -> refers to the specific blog of which we want to access the comments of (blogs/\\[id\\]/comments)\n \n\n#### Request Body\n\n- content (text, required): The content of the comment.\n \n\n#### Response\n\nThe response is a JSON object with the following properties:\n\n- message (string): A message from the server.\n \n- newComment (object): An object representing the newly created comment with the following properties:\n \n - id (number): The unique identifier of the comment.\n \n - authorId (number): The unique identifier of the author of the comment.\n \n - content (string): The content of the comment.\n \n - blogId (number): The unique identifier of the blog on which the comment was made.\n \n - upvote (number): The number of upvotes received by the comment.\n \n - downvote (number): The number of downvotes received by the comment.\n \n - createdAt (string): The timestamp indicating when the comment was created.\n \n - hidden (boolean): Indicates whether the comment is hidden or not.\n \n - parentId (number): The unique identifier of the parent comment, if the comment is a reply to another comment.\n \n\n#### Response Schema\n\n``` json\n{\n \"type\": \"object\",\n \"properties\": {\n \"message\": {\n \"type\": \"string\"\n },\n \"newComment\": {\n \"type\": \"object\",\n \"properties\": {\n \"id\": {\n \"type\": \"number\"\n },\n \"authorId\": {\n \"type\": \"number\"\n },\n \"content\": {\n \"type\": \"string\"\n },\n \"blogId\": {\n \"type\": \"number\"\n },\n \"upvote\": {\n \"type\": \"number\"\n },\n \"downvote\": {\n \"type\": \"number\"\n },\n \"createdAt\": {\n \"type\": \"string\"\n },\n \"hidden\": {\n \"type\": \"boolean\"\n },\n \"parentId\": {\n \"type\": [\"number\", \"null\"]\n }\n },\n \"required\": [\"id\", \"authorId\", \"content\", \"blogId\", \"upvote\", \"downvote\", \"createdAt\", \"hidden\"]\n }\n },\n \"required\": [\"newComment\"]\n}\n\n ```"
},
"response": []
},
{
"name": "rate a comment",
"request": {
"auth": {
"type": "bearer",
"bearer": [
{
"key": "token",