non mongo testing

This commit is contained in:
Julian Anderson 2023-05-10 11:49:48 -06:00
parent c124112118
commit de48998475
6 changed files with 43 additions and 44 deletions

View File

@ -1,20 +1,40 @@
{ {
"themes": { "themes": [
"dark" : { {
"name": "Chan",
"id": "chan"
},
{
"name": "Chan Dark",
"id": "chan_dark"
},
{
"name": "Dark", "name": "Dark",
"id": "dark", "id": "dark"
"description": "Dark", },
"primary_color": "0xFF2A2D34", {
"secondary_color": "0xFF4C86E9", "name": "Forest",
"tertiary_color": "0xFFFFFFFF", "id": "forest"
"background": "0xFF2A2D34", },
"overlay": "0xFF111215", {
"accentColorBlue": "0xFF4C86E9", "name": "Fruit Sorbet",
"accentColorGreen": "0xFF4CC0A0", "id": "fruit_sorbet"
"accentColorYellow": "0xFFF7D65D", },
"accentColorRed": "0xFFD34E50", {
"accentColorOrange": "0xFFFEA68D", "name": "Light",
"accentColorDark": "0xFFF3F3F3" "id": "light"
},
{
"name": "Ocean Breeze",
"id": "ocean_breeze"
},
{
"name": "OLED Black",
"id": "oled_black"
},
{
"name": "Orange",
"id": "orange"
} }
} ]
} }

BIN
data/themes/dark.zip Normal file

Binary file not shown.

BIN
data/themes/light.zip Normal file

Binary file not shown.

View File

@ -1,15 +1,7 @@
function getThemeDetails(id : string) { function getThemeDetails(id : string) {
const fs = require("fs"); const fs = require("fs");
const json_file = fs.readFileSync("data/themes.json"); const theme_file = fs.readFileSync("data/themes/" + id + ".zip");
const json = JSON.parse(json_file); return theme_file;
const themes = json.themes;
var theme = {};
Object.entries(themes).map(([key, value]) => {
if (key == id){
theme = (themes[key])
}
});
return theme
} }
module.exports = getThemeDetails; module.exports = getThemeDetails;

View File

@ -3,20 +3,7 @@ function getThemeList() {
const json_file = fs.readFileSync("data/themes.json"); const json_file = fs.readFileSync("data/themes.json");
const json = JSON.parse(json_file); const json = JSON.parse(json_file);
const themes = json.themes; const themes = json.themes;
var themeArray : Array<Object> = []; return themes;
// For loop that will look for all the themes in the themes.json file
Object.entries(themes).map(([key, value]) => {
var theme : Object = {
"name": themes[key].name,
"id": themes[key].id,
"description": themes[key].description,
"primary_color": themes[key].primary_color, // Primary color is background color in the theme
"secondary_color": themes[key].secondary_color, // Secondary color is the color of the buttonBackPrimary in the theme
"tertiary_color": themes[key].tertiary_color, // Tertiary color is the color of the buttonTextPrimary in the theme
}
themeArray.push(theme);
})
return themeArray;
} }
module.exports = getThemeList; module.exports = getThemeList;

View File

@ -9,16 +9,16 @@ function startServer(port : number) {
app.use(cors()); app.use(cors());
var themeListReqCounter = 0; var themeListReqCounter = 0;
app.get("/themelist", (req : any, res : any) => { app.get("/themes", (req : any, res : any) => {
themeListReqCounter++; themeListReqCounter++;
console.log("Got request on /themelist, request number " + themeListReqCounter) console.log("Got request on /themes, request number " + themeListReqCounter)
res.send(getThemeList()); res.send(getThemeList());
}); });
var themeDetailsReqCounter = 0; var themeDetailsReqCounter = 0;
app.get("/themedetails/:id", (req : any, res : any) => { app.get("/theme/:id", (req : any, res : any) => {
themeDetailsReqCounter++; themeDetailsReqCounter++;
console.log("Got request on /themedetails/" + req.params.id + ", request number " + themeDetailsReqCounter) console.log("Got request on /theme/" + req.params.id + ", request number " + themeDetailsReqCounter)
res.send(getThemeDetails(req.params.id)); res.send(getThemeDetails(req.params.id));
}); });