You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: Readme.md
+44-2Lines changed: 44 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -88,7 +88,49 @@ GET http://localhost:3000/api/v1/comments?limit=2&offset=1
88
88
This project is built using node.js with express.js framework, postgres database using sequelize and third party api integration (SWAPI).
89
89
90
90
It is simple rest api app that use json web token and SWAPI (The Star Wars API). Once register then login and get token.
91
-
and later all requests use jwt token http header(`x-access-token`) for sending authenticated requested
91
+
and later all requests use jwt token http header(`x-access-token`) for sending authenticated requested.
92
+
93
+
```
94
+
SPECIFICATION
95
+
REST API with postgres database and usage of external JSON API with simple json web token authentication. Full specification of routes below:
96
+
97
+
POST /register:
98
+
Request body should containing planet's username and secret in request body.
99
+
Response will return HTTP 201 with empty body.
100
+
101
+
POST /login:
102
+
Request body should containing planet's username and secret in request body.
103
+
Response will return HTTP 200 with the fetched token as response's body.
104
+
105
+
Now below Only authorized request should be allowed, not-authorized requests should receive proper HTTP error.
106
+
107
+
POST /planets:
108
+
Request body should containing planet's name,
109
+
Request data will be validated and accept only name as a string,
110
+
Additional data will be fetched from https://swapi.co/, aginst provided planet name and saved to database,
111
+
response will return HTTP 201 with the fetched data as response's body.
112
+
113
+
GET /planets:
114
+
List all planets from database,
115
+
Pagination, filtering and sorting on id basis is added!
116
+
117
+
GET /planets/:id
118
+
It will return a planet by id from database,
119
+
120
+
POST /comments:
121
+
Request will contains comment's text and planet's ID,
122
+
it will add a comment to a given planet and return that comment as response body.
123
+
124
+
GET /comments:
125
+
it will fetch list of all comments from database and allow for filtering, pagination by planet using /comments?planet=:planet_id&limit=1&offset=1 query parameter.
126
+
127
+
DELETE /planets/:id
128
+
It will remove a given planet from database.
129
+
130
+
PUT /planets/:id
131
+
It will update a given planet by id in database.
132
+
133
+
```
92
134
93
135
#### Backend
94
136
@@ -146,4 +188,4 @@ Postman collection is added for testing in local system and heroku
146
188
*[Node.js ES2015/ES6, ES2016 and ES2017 support](http://node.green/)
147
189
*[SWAPI - The Star Wars API](https://swapi.co/documentation#planets)
0 commit comments