添加导入数据的接口

This commit is contained in:
Peng-YM
2020-10-03 21:32:23 +08:00
parent f257c47fc1
commit e6288b1355
2 changed files with 10 additions and 2 deletions

View File

@@ -90,7 +90,9 @@ $app.route("/api/settings")
$app.get("/api/backup", gistBackup);
// data
$app.get("/api/export", exportData);
$app.route("/api/storage")
.get(exportData)
.post(importData);
$app.all("/", async (req, res) => {
res.send("Hello from Sub-Store! Made with ❤️ by Peng-YM.");
@@ -183,6 +185,12 @@ async function exportData(req, res) {
res.json($.read("#sub-store"));
}
async function importData(req, res) {
const data = req.body;
$.write(JSON.stringify(data), "#sub-store");
res.end();
}
/**************************** API -- Subscriptions ***************************************/
// refresh resource
async function refreshResource(req, res) {

File diff suppressed because one or more lines are too long