Skip to content

Commit 8785b1c

Browse files
author
Gustavo Gómez
authored
Update README.md
1 parent 1aee906 commit 8785b1c

File tree

1 file changed

+280
-1
lines changed

1 file changed

+280
-1
lines changed

README.md

Lines changed: 280 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,280 @@
1-
# coding-test-frontend-nic
1+
2+
3+
# XKCD test project
4+
5+
XKCD is “A webcomic of romance, sarcasm, math, and language” available at https://xkcd.com.
6+
7+
![image1](https://user-images.githubusercontent.com/27861/56590676-16eeb100-65ad-11e9-8a8f-ae9d7f15c331.png)
8+
9+
**Figure 1. Example of XKCD comic**
10+
11+
The goal of this test project is to check your Python and JavaScript skills, requiring you to build a site to manage XKCD comics.
12+
13+
XKCD exposes a simple JSON interface, and the details can be seen at https://xkcd.com/json.html.
14+
15+
The site will allow the creation of users, and the users will be able to insert comics’ metadata into a database (PostgreSQL is preferred).
16+
17+
You need to create two projects, one for the backend and one for the frontend. Backend will provide web services that the frontend can consume.
18+
19+
Both projects should contain deployment instructions (Heroku or Docker based deployments are a bonus). You will provide the code for both projects, forking the original repository. That means you will create two forks (backend and frontend).
20+
21+
Description of backend models and web services as follows (a “*” next to a name means that is required). All bodies and responses must be JSON documents, unless something else is said.
22+
23+
The examples contain MongoDB-like ids, but it is not mandatory to follow that. Numeric ids are also accepted.
24+
25+
## User model
26+
![Screen Shot 2019-04-23 at 11 18 06](https://user-images.githubusercontent.com/27861/56598122-810d5300-65b9-11e9-8e6e-ce09cad36c42.png)
27+
28+
29+
### Methods to be implemented:
30+
31+
**POST /user**
32+
33+
Creates or updates a user.
34+
35+
The password is passed as plain text but must be encrypted when inserted into the database (bcrypt preferred).
36+
37+
- Example of body:
38+
39+
`{
40+
"first_name": "Mike",
41+
"last_name": "Patterson",
42+
"email": "something@mail.com",
43+
"password": "secret123"
44+
}`
45+
46+
- Example of response:
47+
48+
`{
49+
"status": "200",
50+
"message": "The user was created successfully",
51+
"id": "558d6da078fea511752289bd"
52+
}`
53+
54+
When a user is updated the id is required and any parameter can be updated (the id cannot be updated).
55+
56+
- Example of body:
57+
58+
`{
59+
"id": "558d6da078fea511752289bd",
60+
"first_name": "Mike",
61+
"last_name": "Patterson",
62+
"email": "something_different@mail.com",
63+
"password": "secret123"
64+
}`
65+
66+
- Example of response:
67+
68+
`{
69+
"status": "200",
70+
"message": "The user was updated successfully",
71+
"id": "558d6da078fea511752289bd"
72+
}`
73+
74+
75+
- Example of body:
76+
77+
`{
78+
"id": "558d6da078fea511752289bd",
79+
"first_name": "Mike",
80+
"last_name": "Morris"
81+
}`
82+
83+
- Example of response:
84+
85+
`{
86+
"status": "200",
87+
"message": "The user was updated successfully",
88+
"id": "558d6da078fea511752289bd"
89+
}`
90+
91+
Will return status different than 200 in case of errors:
92+
93+
- Examples:
94+
95+
`{
96+
"status": "400",
97+
"message": "User with that email already exists"
98+
}`
99+
100+
`{
101+
"status": "500",
102+
"message": "Server error"
103+
}`
104+
105+
**POST /user/login**
106+
107+
Logs user into the system
108+
109+
Successful login.
110+
111+
- Example of body:
112+
113+
`{
114+
"email": "something@mail.com",
115+
"password": "secret123"
116+
}`
117+
118+
- Example of response:
119+
120+
`{
121+
"status": "200",
122+
"message": "User logged in successfully"
123+
}`
124+
125+
Failed login.
126+
127+
- Example of body:
128+
129+
`{
130+
"email": "something@mail.com",
131+
"password": "badpassw0rd"
132+
}`
133+
134+
- Example of response:
135+
136+
`{
137+
"status": "401",
138+
"message": "Please check your credentials"
139+
}`
140+
141+
**POST /user/logout**
142+
143+
Logs out current logged in user session
144+
145+
Successful request.
146+
147+
- Example of body:
148+
149+
No parameters
150+
151+
- Example of response:
152+
153+
`{
154+
"status": "200",
155+
"message": "User logged out successfully"
156+
}`
157+
158+
## Comic model
159+
![Screen Shot 2019-04-23 at 11 17 00](https://user-images.githubusercontent.com/27861/56598055-58855900-65b9-11e9-83f7-ea4d24de2e63.png)
160+
161+
162+
### Methods to be implemented:
163+
164+
**POST /comic**
165+
166+
Creates or updates a comic
167+
168+
- Example of body:
169+
170+
`{
171+
"month": "6",
172+
"num": 111,
173+
"link": "",
174+
"year": 2006,
175+
"news": "",
176+
"safe_title": "Firefox and Witchcraft - The Connection?",
177+
"transcript": "membership in wicca\ntotal firefox downloads\n[[positive slope graph]]\n[[Internet Explorer icon]]\nKeep the Faith\n[[Outline of a cross]]",
178+
"alt": "ThisadpaidforbythecounciltopromoteMicrosoftandChristianity. Remember, The Bible is Closed Source.",
179+
"img": "https://imgs.xkcd.com/comics/firefox_wicca.png",
180+
"title": "Firefox and Witchcraft - The Connection?",
181+
"day": "5"
182+
}`
183+
184+
- Example of response:
185+
186+
`{
187+
"status": "200",
188+
"message": "The comic was created successfully",
189+
"id": "5a453cfd99b423000bc1d554"
190+
}`
191+
192+
193+
- Example of body:
194+
195+
`{
196+
"id": "5a453cfd99b423000bc1d554",
197+
"month": "6",
198+
"num": 111,
199+
"link": "",
200+
"year": 2006,
201+
"news": "",
202+
"safe_title": "Firefox and Witchcraft - The Connection? (Updated)",
203+
"transcript": "membership in wicca\ntotal firefox downloads\n[[positive slope graph]]\n[[Internet Explorer icon]]\nKeep the Faith\n[[Outline of a cross]]",
204+
"alt": "ThisadpaidforbythecounciltopromoteMicrosoftandChristianity. Remember, The Bible is Closed Source.",
205+
"img": "https://imgs.xkcd.com/comics/firefox_wicca.png",
206+
"title": "Firefox and Witchcraft - The Connection? (Updated)",
207+
"day": "5"
208+
}`
209+
210+
- Example of response:
211+
212+
`{
213+
"status": "200",
214+
"message": "The comic was updated successfully",
215+
"id": "5a453cfd99b423000bc1d554"
216+
}`
217+
218+
**GET /comic/?tag=<query>**
219+
220+
Returns multiple comics which match the tag parameter, as a case insensitive search in the safe_title and transcript fields. The tag can have whitespace between words. It returns an empty document in case there are no matches.
221+
222+
- Example of query:
223+
224+
**GET /comic/?tag=firefox**
225+
226+
- Example of response:
227+
228+
`[
229+
{
230+
"id": "5a453cfd99b423000bc1d555",
231+
"month": "6",
232+
"num": 111,
233+
"link": "",
234+
"year": 2006,
235+
"news": "",
236+
"safe_title": "Firefox and Witchcraft - The Connection?",
237+
"transcript": "membership in wicca\ntotal firefox downloads\n[[positive slope graph]]\n[[Internet Explorer icon]]\nKeep the Faith\n[[Outline of a cross]]",
238+
"alt": "ThisadpaidforbythecounciltopromoteMicrosoftandChristianity. Remember, The Bible is Closed Source.",
239+
"img": "https://imgs.xkcd.com/comics/firefox_wicca.png",
240+
"title": "Firefox and Witchcraft - The Connection?",
241+
"day": "5"
242+
},
243+
{
244+
"id": "5a453cfd99b423000bc1d556",
245+
"month": "12",
246+
"num": 1045,
247+
"link": "",
248+
"year": 2008,
249+
"news": "",
250+
"safe_title": "Web Browsers",
251+
"transcript": "this is just an example of Chrome and Firefox",
252+
"title": "Chrome and Firefox",
253+
"day": "23"
254+
}
255+
]`
256+
257+
****DELETE /comic/<comic_id>****
258+
259+
Deletes a comic using an id.
260+
261+
- Example of query:
262+
263+
**DELETE /comic/5a453cfd99b423000bc1d556**
264+
265+
- Example of response:
266+
267+
`{
268+
"status": "200",
269+
"message": "The comic was deleted successfully",
270+
"id": "5a453cfd99b423000bc1d556"
271+
}`
272+
273+
274+
## Final notes
275+
276+
Not all methods should require authentication, only actions that require creating something in the database should have it (this includes session management).
277+
278+
You are free to design the frontend site as you wish, but at least it should be able to show the comics as images in case the user performs a query (Angular is preferred).
279+
280+
Please send a pull request against the master branch of the upstream repository once you finish the implementation.

0 commit comments

Comments
 (0)