60 lines
1.3 KiB
JavaScript
60 lines
1.3 KiB
JavaScript
import Router from 'express-promise-router';
|
|
|
|
import {
|
|
syncScenes,
|
|
syncMovies,
|
|
syncActors,
|
|
syncStashes,
|
|
syncQueue,
|
|
} from '../sync.js';
|
|
|
|
import verifyAbility from '../../utils/verify-ability.js';
|
|
|
|
export const syncRouter = Router();
|
|
|
|
async function syncScenesApi(req, res) {
|
|
verifyAbility(req.user, 'sync', null, { throwError: true });
|
|
|
|
await syncScenes(req.body.sceneIds);
|
|
|
|
res.status(204).send();
|
|
}
|
|
|
|
async function syncMoviesApi(req, res) {
|
|
verifyAbility(req.user, 'sync', null, { throwError: true });
|
|
|
|
await syncMovies(req.body.movieIds);
|
|
|
|
res.status(204).send();
|
|
}
|
|
|
|
async function syncActorsApi(req, res) {
|
|
verifyAbility(req.user, 'sync', null, { throwError: true });
|
|
|
|
await syncActors(req.body.actorIds);
|
|
|
|
res.status(204).send();
|
|
}
|
|
|
|
async function syncStashesApi(req, res) {
|
|
verifyAbility(req.user, 'sync', null, { throwError: true });
|
|
|
|
await syncStashes(req.body.stashIds);
|
|
|
|
res.status(204).send();
|
|
}
|
|
|
|
async function syncQueueApi(req, res) {
|
|
verifyAbility(req.user, 'sync', null, { throwError: true });
|
|
|
|
await syncQueue();
|
|
|
|
res.status(204).send();
|
|
}
|
|
|
|
syncRouter.post('/api/sync/scenes', syncScenesApi);
|
|
syncRouter.post('/api/sync/movies', syncMoviesApi);
|
|
syncRouter.post('/api/sync/actors', syncActorsApi);
|
|
syncRouter.post('/api/sync/stashes', syncStashesApi);
|
|
syncRouter.post('/api/sync', syncQueueApi);
|