Skip to content

Commit e1196c2

Browse files
authored
v1.1.5 - Routes Documentation & Home Page Update (#41)
* docs * cleanup * cleanup * adjust pipe route * version * cleanup
1 parent a2af64e commit e1196c2

File tree

10 files changed

+212
-81
lines changed

10 files changed

+212
-81
lines changed

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "jetsetradio-api",
3-
"version": "1.1.4",
3+
"version": "1.1.5",
44
"description": "A Data Provider relating to the JSR/JSRF universe",
55
"type": "module",
66
"main": "src/app.js",

src/docs/DEV_SETUP.md

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -35,18 +35,15 @@ This page will guide you on setting up a development environment for this projec
3535
LOG_LEVEL=info
3636

3737
# MONGO CONNECT (get from connection string)
38-
MONGO_USER=
39-
MONGO_PASS=
40-
MONGO_CLUSTER=
41-
MONGO_DOMAIN=
38+
MONGO_URI=
4239

4340
# MONGO DATABASES (names do not matter)
4441
JSR_DB=
4542
JSRF_DB=
4643
BRC_DB
4744
CORE_DB=
4845
```
49-
The databases section in the env file are names of the databases. For development purposes it does not matter what these names are just as long as you can distinguish one from the other and you know which one is which.
46+
The databases section in the env file are names of the databases. For development purposes it does not matter what these names are but I recommend labeling it as QA-JSR, QA-JSRF, QA-BRC, or something similar.
5047

5148
6. Run the project
5249
```sh

src/managers/MiddlewareManager.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,7 @@ const filterPipeRoutes = async (req, endpoints) => {
103103
if (
104104
((jsrCollections.includes(model) ||
105105
jsrCollections.includes(model + "s")) &&
106+
!endpoint.includes("random") &&
106107
endpoint.includes("jsr")) ||
107108
endpoint.includes("levels")
108109
) {
@@ -111,12 +112,14 @@ const filterPipeRoutes = async (req, endpoints) => {
111112
if (
112113
(jsrfCollections.includes(model) ||
113114
jsrCollections.includes(model + "s")) &&
114-
endpoint.includes("jsrf")
115+
endpoint.includes("jsrf") &&
116+
!endpoint.includes("random")
115117
) {
116118
filteredEndpoints.push(endpoint);
117119
}
118120
if (
119121
brcCollections.includes(model) &&
122+
!endpoint.includes("random") &&
120123
(endpoint.includes("brc") || endpoint.includes("collectibles"))
121124
) {
122125
filteredEndpoints.push(endpoint);

src/public/index.html

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,18 @@
1313
name="keywords"
1414
content="jet set radio, api, documentation, bomb rush cyberfunk, video game"
1515
/>
16+
<meta name="author" content="Jet Set Radio API Community" />
17+
<meta property="og:title" content="Jet Set Radio API" />
18+
<meta
19+
property="og:description"
20+
content="Integrate Jet Set Radio, JSRF, and Bomb Rush Cyberfunk data into your applications with this free API."
21+
/>
22+
<meta
23+
property="og:image"
24+
content="https://jetsetradio-api.onrender.com/img/jsrapi-wallpaper.webp"
25+
/>
26+
<meta property="og:url" content="https://jetsetradio-api.onrender.com/" />
27+
<meta name="twitter:card" content="summary_large_image" />
1628
<title>Jet Set Radio API</title>
1729
<link rel="canonical" href="https://jetsetradio-api.onrender.com/" />
1830
<link rel="stylesheet" href="./style/index.css" />
@@ -29,13 +41,17 @@ <h2>JSRAPI</h2>
2941
<div class="main-container text-center">
3042
<p>
3143
All The Data from Jet Set Radio, Jet Set Radio Future, and Bomb Rush
32-
Cyberfunk you could want
44+
Cyberfunk you could want in JSON format.
3345
</p>
3446
<p>games, characters, songs, graffiti-tags, locations, and more!</p>
3547
<p>
3648
Check out the <a class="inline-a" href="/docs">documentation</a> to
3749
get started
3850
</p>
51+
<p>
52+
Click <a class="inline-a" href="/api-docs">here</a> to view a list of
53+
available endpoints
54+
</p>
3955
<p>
4056
Interested in contributing to the project? Check out the
4157
<a
@@ -50,6 +66,7 @@ <h2>JSRAPI</h2>
5066
</p>
5167
</div>
5268
</div>
69+
<div id="api-docs"></div>
5370
<footer>
5471
<a href="https://github.com/Jet-Set-Radio-API/JetSetRadio-API"
5572
><img src="./img/github.webp" alt="github-page-link"
@@ -58,5 +75,10 @@ <h2>JSRAPI</h2>
5875
><img src="./img/swagger.webp" alt="swagger-docs-button"
5976
/></a>
6077
</footer>
78+
79+
<script type="module">
80+
import {createApiTable} from "/js/apiTable.js";
81+
document.getElementById("api-docs").appendChild(createApiTable());
82+
</script>
6183
</body>
6284
</html>

src/public/js/apiTable.js

Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
/* Displays a Table on the home page Showing Some Available Endpoints */
2+
export function createApiTable() {
3+
const container = document.createElement("div");
4+
container.className = "api-table-container";
5+
6+
const table = document.createElement("table");
7+
table.className = "api-table";
8+
9+
const headerRow = document.createElement("tr");
10+
["Endpoint", "Description"].forEach((text) => {
11+
const th = document.createElement("th");
12+
th.textContent = text;
13+
headerRow.appendChild(th);
14+
});
15+
table.appendChild(headerRow);
16+
17+
const baseUrl = "https://jetsetradio-api.onrender.com";
18+
const rows = [
19+
{
20+
endpoint: "/v1/api/audio/jsrf?speaker=DJ Professor K",
21+
description: "Returns all quotes/audio from DJ Professor K from JSRF",
22+
},
23+
{
24+
endpoint: "/v1/api/games",
25+
description:
26+
"Lists all games in the Jet Set Radio series and surrounding games",
27+
},
28+
{
29+
endpoint: "/v1/api/songs/brc",
30+
description: "Returns all songs in Bomb Rush Cyberfunk",
31+
},
32+
{
33+
endpoint: "/v1/api/characters",
34+
description: "Returns character information from all games",
35+
},
36+
{
37+
endpoint: "/v1/api/characters/jsrf",
38+
description: "Returns character information from Jet Set Radio Future",
39+
},
40+
{
41+
endpoint: "/v1/api/songs/random?count=3",
42+
description:
43+
"Returns 3 random songs from any game. The /random route works on most endpoints.",
44+
},
45+
{
46+
endpoint: "/v1/api/artists/643865b4af5362b86b844d60/songs",
47+
description:
48+
"Returns all songs by an artist. This example is Hideki Naganuma",
49+
},
50+
{
51+
endpoint: "/v1/api/locations/random?game=jsr",
52+
description:
53+
"Returns a random location from Jet Set Radio/Jet Grind Radio",
54+
},
55+
{
56+
endpoint: "/v1/api/graffitiTags?size=L",
57+
description: "Returns all Large Graffiti Tags from any game",
58+
},
59+
{
60+
endpoint: "/v1/api/collectibles?type=Outfit",
61+
description: "Returns all Outfit collectibles from Bomb Rush Cyberfunk",
62+
},
63+
];
64+
65+
rows.forEach(({endpoint, description}) => {
66+
const tr = document.createElement("tr");
67+
68+
const tdEndpoint = document.createElement("td");
69+
const link = document.createElement("a");
70+
link.href = `${baseUrl}${endpoint}`;
71+
link.textContent = endpoint;
72+
link.target = "_blank";
73+
link.rel = "noopener noreferrer";
74+
link.style.color = "inherit"; // keep the same color as the table text
75+
link.style.textDecoration = "none";
76+
tdEndpoint.appendChild(link);
77+
78+
const tdDesc = document.createElement("td");
79+
tdDesc.textContent = description;
80+
81+
tr.appendChild(tdEndpoint);
82+
tr.appendChild(tdDesc);
83+
table.appendChild(tr);
84+
});
85+
86+
container.appendChild(table);
87+
return container;
88+
}

src/public/js/docs.js

Lines changed: 27 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -8,56 +8,32 @@ import artistResource from "./examples/artistExample.js";
88
import collectibleResource from "./examples/collectibleExample.js";
99
import audioResource from "./examples/audioExample.js";
1010

11-
const gameResponse = document.querySelector('#game-response');
12-
if (gameResponse) {
13-
gameResponse.textContent = JSON.stringify(gameResource, null, 4);
14-
}
15-
const characterResponse = document.querySelector('#character-response');
16-
if (characterResponse) {
17-
characterResponse.textContent = JSON.stringify(characterResource, null, 4);
18-
}
19-
const locationResponse = document.querySelector('#location-response');
20-
if (locationResponse) {
21-
locationResponse.textContent = JSON.stringify(locationResource, null, 4);
22-
}
23-
const levelResponse = document.querySelector('#level-response');
24-
if (levelResponse) {
25-
levelResponse.textContent = JSON.stringify(levelResource, null, 4);
26-
}
27-
const graffitiTagResponse = document.querySelector('#graffiti-tag-response');
28-
if (graffitiTagResponse) {
29-
graffitiTagResponse.textContent = JSON.stringify(graffitiTagResource, null, 4);
30-
}
31-
const songResponse = document.querySelector('#song-response');
32-
if (songResponse) {
33-
songResponse.textContent = JSON.stringify(songResource, null, 4);
34-
}
35-
const artistResponse = document.querySelector('#artist-response');
36-
if (artistResponse) {
37-
artistResponse.textContent = JSON.stringify(artistResource, null, 4);
38-
}
39-
const collectibleResponse = document.querySelector('#collectible-response');
40-
if (collectibleResponse) {
41-
collectibleResponse.textContent = JSON.stringify(collectibleResource, null, 4);
42-
}
43-
const audioResponse = document.querySelector('#audio-response');
44-
if (audioResponse) {
45-
audioResponse.textContent = JSON.stringify(audioResource, null, 4);
46-
}
11+
const resources = [
12+
{selector: "#game-response", data: gameResource},
13+
{selector: "#character-response", data: characterResource},
14+
{selector: "#location-response", data: locationResource},
15+
{selector: "#level-response", data: levelResource},
16+
{selector: "#graffiti-tag-response", data: graffitiTagResource},
17+
{selector: "#song-response", data: songResource},
18+
{selector: "#artist-response", data: artistResource},
19+
{selector: "#collectible-response", data: collectibleResource},
20+
{selector: "#audio-response", data: audioResource},
21+
];
4722

48-
const expandableButtons = document.querySelectorAll(".expandable-button");
49-
if (expandableButtons) {
50-
expandableButtons.forEach(button => {
51-
button.addEventListener("click", () => {
52-
if (!button.classList.contains('expanded')) {
53-
button.classList.add('expanded');
54-
button.textContent = 'Collapse';
55-
} else {
56-
button.classList.remove('expanded');
57-
button.textContent = 'Expand';
58-
}
59-
const content = button.parentElement.nextElementSibling;
60-
content.style.display = content.style.display === "none" ? "block" : "none";
61-
});
23+
resources.forEach(({selector, data}) => {
24+
const el = document.querySelector(selector);
25+
if (el) el.textContent = JSON.stringify(data, null, 4);
26+
});
27+
28+
// Expand/collapse buttons
29+
document.querySelectorAll(".expandable-button").forEach((button) => {
30+
button.addEventListener("click", () => {
31+
const expanded = button.classList.toggle("expanded");
32+
button.textContent = expanded ? "Collapse" : "Expand";
33+
34+
const content = button.parentElement.nextElementSibling;
35+
if (content) {
36+
content.style.display = expanded ? "block" : "none";
37+
}
6238
});
63-
}
39+
});

src/public/style/index.css

Lines changed: 49 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,12 @@ a {
1919

2020
@font-face {
2121
font-family: jetSet;
22-
src: url('/font/Jet-Set.ttf');
22+
src: url("/font/Jet-Set.ttf");
2323
}
2424

2525
@font-face {
2626
font-family: jetSetItalic;
27-
src: url('/font/Jet-Set-Italic.ttf');
27+
src: url("/font/Jet-Set-Italic.ttf");
2828
}
2929

3030
#img-container {
@@ -46,11 +46,12 @@ a {
4646
position: absolute;
4747
left: 50%;
4848
top: 50%;
49-
transform: translate(-50%,-50%);
49+
transform: translate(-50%, -50%);
5050
font-size: 5.5vw;
5151
}
5252

53-
#documentation, #swagger {
53+
#documentation,
54+
#swagger {
5455
position: absolute;
5556
right: 3%;
5657
top: 3%;
@@ -102,4 +103,47 @@ footer a img {
102103
width: 100%;
103104
height: auto;
104105
min-width: 50px;
105-
}
106+
}
107+
108+
/* API TABLE */
109+
.api-table-container {
110+
width: 100%;
111+
overflow-x: auto;
112+
margin-top: 4rem;
113+
padding: 0 6rem;
114+
}
115+
116+
.api-table {
117+
font-family: jetSet;
118+
width: 100%;
119+
border-collapse: collapse;
120+
}
121+
122+
.api-table th,
123+
.api-table td {
124+
border: 1px solid #747474;
125+
padding: 1rem;
126+
text-align: left;
127+
vertical-align: top;
128+
}
129+
130+
.api-table th {
131+
background: #1ed31e7b;
132+
font-size: 1.3rem;
133+
}
134+
.api-table td {
135+
font-size: 1.2rem;
136+
}
137+
138+
.api-table th:nth-child(2) {
139+
text-align: right;
140+
}
141+
142+
.api-table td:first-child {
143+
width: 40%; /* endpoint column */
144+
}
145+
146+
.api-table td:nth-child(2) {
147+
width: 40%; /* endpoint column */
148+
text-align: right;
149+
}

0 commit comments

Comments
 (0)