Skip to content

Commit

Permalink
feat: Added replaceArtifact API
Browse files Browse the repository at this point in the history
  • Loading branch information
xream committed Aug 18, 2023
1 parent 4a0319e commit 4dd86cb
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
2 changes: 1 addition & 1 deletion backend/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "sub-store",
"version": "2.14.12",
"version": "2.14.13",
"description": "Advanced Subscription Manager for QX, Loon, Surge, Stash and ShadowRocket.",
"main": "src/main.js",
"scripts": {
Expand Down
13 changes: 11 additions & 2 deletions backend/src/restful/artifacts.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,10 @@ export default function register($app) {
if (!$.read(ARTIFACTS_KEY)) $.write({}, ARTIFACTS_KEY);

// RESTful APIs
$app.route('/api/artifacts').get(getAllArtifacts).post(createArtifact);
$app.route('/api/artifacts')
.get(getAllArtifacts)
.post(createArtifact)
.put(replaceArtifact);

$app.route('/api/artifact/:name')
.get(getArtifact)
Expand All @@ -32,6 +35,12 @@ function getAllArtifacts(req, res) {
success(res, allArtifacts);
}

function replaceArtifact(req, res) {
const allArtifacts = req.body;
$.write(allArtifacts, ARTIFACTS_KEY);
success(res);
}

async function getArtifact(req, res) {
let { name } = req.params;
name = decodeURIComponent(name);
Expand Down Expand Up @@ -131,7 +140,7 @@ async function deleteArtifact(req, res) {
files[encodeURIComponent(artifact.name)] = {
content: '',
};
// 当别的Sub 删了同步订阅 或 gist里面删了 当前设备没有删除 时 无法删除的bug
// 当别的Sub 删了同步订阅 或 gist里面删了 当前设备没有删除 时 无法删除的bug
try {
await syncToGist(files);
} catch (i) {
Expand Down

0 comments on commit 4dd86cb

Please sign in to comment.