-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathReadme.txt
155 lines (96 loc) · 3.45 KB
/
Readme.txt
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
Before running
nodemon index.js
to start the server in VS Code please
1) Create the .env File
it should contain
port = 456 // 456 should be the port that you use in development
dbconfig = {"connectionLimit": 10,"user": "root","password": "your passsword for root","host": "localhost","database": "database name that you use"}
2) Install all the dependencies in the package-lock.json file using the command
npm install
After the server successfully starts
Use the following endpoints to interact with the server
......................Authentication End points
login POST > localhost:3000/auth/login
include this in the body as a JSON object
{
"UserName" : "[email protected]",
"pass" : "password"
}
* Please note that after login user gets invalidated after 500 minutes
logout DELETE > localhost:3000/api/logout
change passsword POST > localhost:3000/api/changepass
include this in the body as a JSON object
{
"currpassword": "pass",
"newpassword" : "password"
}
signup POST > localhost:3000/auth/signup
Here type can be a) admin or b)regular
{
"UserName" : "[email protected]",
"pass" : "pass",
"type" : "admin",
"fname": "meelan",
"lname": "bandara"
}
......................User Action containing End points for Space Object Handling
Add Astronomy object POST > localhost:3000/api/AddAstrObj error
{
"Tag" : "object name",
"Image" : "url",
"CardText": "cardtext",
"Desc" : "description",
"tStamp": "time stamp"
}
Edit Astronomy object PUT > localhost:3000/api/EditAstrObj
{
"ID" : "id",
"Image" : "url",
"CardText": "cardtext",
"Desc" : "description",
"tStamp": "time stamp"
}
Here ID should be defined but desc, cardtext, image are not compulsory
Edit Planet object PUT > localhost:3000/api/EditPlanet
{
"ID" : "id",
"Image" : "url",
"CardText": "cardtext",
"Desc" : "description",
"tStamp": "time stamp"
}
Here also above condition holds
Get list of astro objects GET > localhost:3000/api/getAstrList?count=5&tbName=astronomical_object
Here count is the number of rows that you need from the DB. tbName is either astronomical_object or planet
according to the requirement.
Get an Astro Object GET > localhost:3000/api/getAstrObj?id=idvalue
Get a planet Object GET > localhost:3000/api/getPlanet?id=idval
.......................User Action containing End points for news object handling
Add a news POST > localhost:3000/api/AddNews
{
"Title":"title",
"Image":"imageurl",
"CardText": "CDTEXT",
"Desc" : "data",
"tStamp": "timestamp"
}
Edit a news PUT > localhost:3000/api/EditNews
{
"id":"news_id as an integer"
"Title":"title",
"Image":"imageurl",
"CardText": "CDTEXT",
"Desc" : "data",
"tStamp": "timestamp"
}
Fetch news list GET > localhost:3000/api/getNewsList?count=5
* Please Note that the count refers for the number of news articles required
Fetch a news GET > localhost:3000/api/getNews?id=2
* Here id refers to the news_id of the required news object. You will have to pass it on from the FO
Add a comment POST > localhost:3000/api/addComment?id=2&comment=comment body
{
"id": "news_id as an integer",
"Comment" : "comment"
}
Get all the comments GET > localhost:3000/api/getComment?id=1
* Here id refers to the news_id of the required news object. You will have to pass it on from the FO