Skip to content

Commit ae4ff1d

Browse files
authored
Merge pull request #1 from Steppico/fix/updates-and-improvements
Fix/updates and improvements
2 parents cb3622c + 9269411 commit ae4ff1d

File tree

3 files changed

+18
-18
lines changed

3 files changed

+18
-18
lines changed

README.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -44,15 +44,15 @@ Returns an array with `{number}` quotes e.g. `GET /quotes/3`.
4444
}
4545
]
4646

47-
### `GET /quote/{id}`
47+
### `GET /quotes/id/{id}`
4848

4949
Get the corresponding quote from its `id` in this format:
5050

51-
> [https://the-dune-api.herokuapp.com/quote/40](https://the-dune-api.herokuapp.com/quote/40)
51+
> [https://the-dune-api.herokuapp.com/quotes/id/66](https://the-dune-api.herokuapp.com/quotes/id/66)
5252
5353
[
5454
{
55-
id: "96",
55+
id: "66",
5656
"quote": "A man's flesh is his own; the water belongs to the tribe.",
5757
}
5858
]
@@ -103,11 +103,11 @@ Returns an array with `{number}` books e.g. `GET /books/3`.
103103
}
104104
]
105105

106-
### `GET /book/{id}`
106+
### `GET /books/id/{id}`
107107

108108
Get the corresponding book from its `id` in this format:
109109

110-
> [https://the-dune-api.herokuapp.com/book/1](https://the-dune-api.herokuapp.com/book/1)
110+
> [https://the-dune-api.herokuapp.com/books/id/1](https://the-dune-api.herokuapp.com/books/id/1)
111111
112112
[
113113
{

loaders/getArticle.js

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -83,8 +83,8 @@ function getRandom(type, number) {
8383

8484
function getArticle(type, id) {
8585
if (type == 'quotes') {
86-
if (id < 0) {
87-
return quotes[1]
86+
if (id <= 0) {
87+
return quotes[0]
8888
}
8989
else if (id > quotes.length) {
9090
return quotes[quotes.length - 1]
@@ -94,8 +94,8 @@ function getArticle(type, id) {
9494
}
9595
}
9696
else if (type == 'books') {
97-
if (id < 0) {
98-
return books[1]
97+
if (id <= 0) {
98+
return books[0]
9999
}
100100
else if (id > books.length) {
101101
return books[books.length - 1]
@@ -105,8 +105,8 @@ function getArticle(type, id) {
105105
}
106106
}
107107
else if (type == 'movies') {
108-
if (id < 0) {
109-
return movies[1]
108+
if (id <= 0) {
109+
return movies[0]
110110
}
111111
else if (id > movies.length) {
112112
return movies[movies.length - 1]
@@ -116,8 +116,8 @@ function getArticle(type, id) {
116116
}
117117
}
118118
else if (type == 'series') {
119-
if (id < 0) {
120-
return series[1]
119+
if (id <= 0) {
120+
return series[0]
121121
}
122122
else if (id > series.length) {
123123
return series[series.length - 1]
@@ -127,8 +127,8 @@ function getArticle(type, id) {
127127
}
128128
}
129129
else if (type == 'stories') {
130-
if (id < 0) {
131-
return shortStories[1]
130+
if (id <= 0) {
131+
return shortStories[0]
132132
}
133133
else if (id > stories.length) {
134134
return shortStories[shortStories.length - 1]
@@ -138,8 +138,8 @@ function getArticle(type, id) {
138138
}
139139
}
140140
else if (type == 'comics') {
141-
if (id < 0) {
142-
return comics[1]
141+
if (id <= 0) {
142+
return comics[0]
143143
}
144144
else if (id > comics.length) {
145145
return comics[comics.length - 1]

server.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ app.get('/:type/id/:id?', function (req, res) {
2323
});
2424

2525
app.get('/', (req, res) => {
26-
res.status(200).status(200).send("Welcome to the DUNE API")
26+
res.status(200).send("Welcome to the DUNE API")
2727
});
2828

2929
app.listen(PORT, function () {

0 commit comments

Comments
 (0)