Skip to content

Commit fedee1f

Browse files
authored
Merge pull request #277 from lille-morille/feat/categorized-snippets-by-language
[Feature] Added endpoint for retrieving snippets by category
2 parents 99fcdbc + 8d40652 commit fedee1f

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

backend/index.ts

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,21 @@ app.get("/languages", (_req, res) => {
4848
return;
4949
});
5050

51+
// Get all content (consolidated file) for language
52+
app.get("/languages/:language", (req, res) => {
53+
const { language } = req.params;
54+
55+
const file = path.join(dataDir, `consolidated/${language}.json`);
56+
const json = readJSON(file);
57+
if (!json) {
58+
res.status(404).json({ error: "Language file not found" });
59+
return;
60+
}
61+
62+
res.json(json);
63+
return;
64+
});
65+
5166
// Get all categories for a given language
5267
app.get("/categories/:language", (req, res) => {
5368
const { language } = req.params;

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy