Added manticore sync API.
This commit is contained in:
@@ -16,6 +16,7 @@ import initRestrictionHandler from './restrictions.js';
|
||||
|
||||
import { scenesRouter } from './scenes.js';
|
||||
import { actorsRouter } from './actors.js';
|
||||
import { syncRouter } from './sync.js';
|
||||
|
||||
import { fetchMoviesApi } from './movies.js';
|
||||
import { fetchEntitiesApi } from './entities.js';
|
||||
@@ -122,11 +123,7 @@ export default async function initServer() {
|
||||
|
||||
router.use('/api/*', async (req, _res, next) => {
|
||||
if (req.headers['api-user']) {
|
||||
await verifyKey(req.headers['api-user'], req.headers['api-key'], req);
|
||||
|
||||
req.user = { // eslint-disable-line no-param-reassign
|
||||
id: Number(req.headers['api-user']),
|
||||
};
|
||||
req.user = await verifyKey(req.headers['api-user'], req.headers['api-key'], req);
|
||||
}
|
||||
|
||||
next();
|
||||
@@ -150,6 +147,7 @@ export default async function initServer() {
|
||||
router.use(alertsRouter);
|
||||
router.use(scenesRouter);
|
||||
router.use(actorsRouter);
|
||||
router.use(syncRouter);
|
||||
|
||||
// MOVIES
|
||||
router.get('/api/movies', fetchMoviesApi);
|
||||
|
||||
49
src/web/sync.js
Normal file
49
src/web/sync.js
Normal file
@@ -0,0 +1,49 @@
|
||||
import Router from 'express-promise-router';
|
||||
|
||||
import {
|
||||
syncScenes,
|
||||
syncMovies,
|
||||
syncActors,
|
||||
syncStashes,
|
||||
} 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();
|
||||
}
|
||||
|
||||
syncRouter.post('/api/sync/scenes', syncScenesApi);
|
||||
syncRouter.post('/api/sync/movies', syncMoviesApi);
|
||||
syncRouter.post('/api/sync/actors', syncActorsApi);
|
||||
syncRouter.post('/api/sync/stashes', syncStashesApi);
|
||||
Reference in New Issue
Block a user