mirror of
https://git.mirrors.martin98.com/https://github.com/sub-store-org/Sub-Store.git
synced 2025-08-14 17:15:55 +08:00
feat: Added replaceSubscriptions, replaceCollection API
This commit is contained in:
parent
c5746f6a6b
commit
048344268c
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "sub-store",
|
"name": "sub-store",
|
||||||
"version": "2.14.9",
|
"version": "2.14.10",
|
||||||
"description": "Advanced Subscription Manager for QX, Loon, Surge, Stash and ShadowRocket.",
|
"description": "Advanced Subscription Manager for QX, Loon, Surge, Stash and ShadowRocket.",
|
||||||
"main": "src/main.js",
|
"main": "src/main.js",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
|
@ -14,7 +14,8 @@ export default function register($app) {
|
|||||||
|
|
||||||
$app.route('/api/collections')
|
$app.route('/api/collections')
|
||||||
.get(getAllCollections)
|
.get(getAllCollections)
|
||||||
.post(createCollection);
|
.post(createCollection)
|
||||||
|
.put(replaceCollection);
|
||||||
}
|
}
|
||||||
|
|
||||||
// collection API
|
// collection API
|
||||||
@ -111,3 +112,9 @@ function getAllCollections(req, res) {
|
|||||||
const allCols = $.read(COLLECTIONS_KEY);
|
const allCols = $.read(COLLECTIONS_KEY);
|
||||||
success(res, allCols);
|
success(res, allCols);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function replaceCollection(req, res) {
|
||||||
|
const allCols = req.body;
|
||||||
|
$.write(allCols, COLLECTIONS_KEY);
|
||||||
|
success(res);
|
||||||
|
}
|
||||||
|
@ -20,7 +20,10 @@ export default function register($app) {
|
|||||||
.patch(updateSubscription)
|
.patch(updateSubscription)
|
||||||
.delete(deleteSubscription);
|
.delete(deleteSubscription);
|
||||||
|
|
||||||
$app.route('/api/subs').get(getAllSubscriptions).post(createSubscription);
|
$app.route('/api/subs')
|
||||||
|
.get(getAllSubscriptions)
|
||||||
|
.post(createSubscription)
|
||||||
|
.put(replaceSubscriptions);
|
||||||
}
|
}
|
||||||
|
|
||||||
// subscriptions API
|
// subscriptions API
|
||||||
@ -66,10 +69,10 @@ async function getFlowInfo(req, res) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// unit is KB
|
// unit is KB
|
||||||
const uploadMatch = flowHeaders.match(/upload=(-?)(\d+)/)
|
const uploadMatch = flowHeaders.match(/upload=(-?)(\d+)/);
|
||||||
const upload = Number(uploadMatch[1] + uploadMatch[2]);
|
const upload = Number(uploadMatch[1] + uploadMatch[2]);
|
||||||
|
|
||||||
const downloadMatch = flowHeaders.match(/download=(-?)(\d+)/)
|
const downloadMatch = flowHeaders.match(/download=(-?)(\d+)/);
|
||||||
const download = Number(downloadMatch[1] + downloadMatch[2]);
|
const download = Number(downloadMatch[1] + downloadMatch[2]);
|
||||||
|
|
||||||
const total = Number(flowHeaders.match(/total=(\d+)/)[1]);
|
const total = Number(flowHeaders.match(/total=(\d+)/)[1]);
|
||||||
@ -202,3 +205,9 @@ function getAllSubscriptions(req, res) {
|
|||||||
const allSubs = $.read(SUBS_KEY);
|
const allSubs = $.read(SUBS_KEY);
|
||||||
success(res, allSubs);
|
success(res, allSubs);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function replaceSubscriptions(req, res) {
|
||||||
|
const allSubs = req.body;
|
||||||
|
$.write(allSubs, SUBS_KEY);
|
||||||
|
success(res);
|
||||||
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user