mirror of
https://git.mirrors.martin98.com/https://github.com/sub-store-org/Sub-Store.git
synced 2026-04-07 11:53:22 +08:00
Minor changes
This commit is contained in:
27
backend/src/restful/settings.js
Normal file
27
backend/src/restful/settings.js
Normal file
@@ -0,0 +1,27 @@
|
||||
import { SETTINGS_KEY } from './constants';
|
||||
import $ from '../core/app';
|
||||
|
||||
export default function register($app) {
|
||||
if (!$.read(SETTINGS_KEY)) $.write({}, SETTINGS_KEY);
|
||||
$app.route('/api/settings').get(getSettings).patch(updateSettings);
|
||||
}
|
||||
|
||||
function getSettings(req, res) {
|
||||
const settings = $.read(SETTINGS_KEY);
|
||||
res.json(settings);
|
||||
}
|
||||
|
||||
function updateSettings(req, res) {
|
||||
const data = req.body;
|
||||
const settings = $.read(SETTINGS_KEY);
|
||||
$.write(
|
||||
{
|
||||
...settings,
|
||||
...data,
|
||||
},
|
||||
SETTINGS_KEY,
|
||||
);
|
||||
res.json({
|
||||
status: 'success',
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user