Archived
1
0

POST for Application Settings working

This commit is contained in:
Sean Edmunds
2022-05-19 18:05:12 -05:00
parent 6e878aa898
commit 312e9ca11f
9 changed files with 641 additions and 204 deletions

View File

@@ -1,8 +1,8 @@
const express = require("express");
const bodyParser = require("body-parser");
const cors = require("cors");
const fs = require("fs");
const applications = require('../src/apps.json');
const links = require('../src/links.json');
const providers = require('../src/providers.json');
const themes = require('../src/themes.json');
@@ -14,10 +14,16 @@ const app = express();
// initializing cors middleware for all routes
app.use(cors());
var jsonParser = bodyParser.json();
// creating route to make request to server for API
app.get("/sui/api/apps", (req, res) => {
res.status(200).send(applications.apps);
fs.readFile('../src/apps.json', (err, data) => {
if (err) throw err;
let test = JSON.parse(data);
res.status(200).send(test.apps);
});
});
app.get("/sui/api/links", (req, res) => {
@@ -40,6 +46,13 @@ app.get("/sui/api/messages", (req, res) => {
res.status(200).send(messages.messages);
});
app.post("/sui/api/appUpdate", jsonParser, (req, res) => {
let data = JSON.stringify(req.body)
fs.writeFileSync('../src/apps.json',data)
var applications = require('../src/apps.json');
res.status(200).send(applications.apps)
});
// app is listening on port 5000