Added experimental edit page and revision history.
This commit is contained in:
@@ -22,6 +22,7 @@ export default async function mainHandler(req, res, next) {
|
||||
id: req.user.id,
|
||||
username: req.user.username,
|
||||
email: req.user.email,
|
||||
role: req.user.role,
|
||||
avatar: req.user.avatar,
|
||||
},
|
||||
assets: req.user ? {
|
||||
|
||||
@@ -1,9 +1,15 @@
|
||||
import { stringify } from '@brillout/json-serializer/stringify'; /* eslint-disable-line import/extensions */
|
||||
|
||||
import { fetchScenes, fetchScenesById } from '../scenes.js';
|
||||
import {
|
||||
fetchScenes,
|
||||
fetchScenesById,
|
||||
createSceneRevision,
|
||||
} from '../scenes.js';
|
||||
|
||||
import { parseActorIdentifier } from '../query.js';
|
||||
import { getIdsBySlug } from '../cache.js';
|
||||
import slugify from '../../utils/slugify.js';
|
||||
import { HttpError } from '../errors.js';
|
||||
import promiseProps from '../../utils/promise-props.js';
|
||||
|
||||
export async function curateScenesQuery(query) {
|
||||
@@ -197,6 +203,18 @@ export async function fetchScenesGraphql(query, req) {
|
||||
};
|
||||
}
|
||||
|
||||
export async function fetchSceneApi(req, res) {
|
||||
const [scene] = await fetchScenesById([Number(req.params.sceneId)], { reqUser: req.user });
|
||||
|
||||
console.log(req.params.sceneId, scene);
|
||||
|
||||
if (!scene) {
|
||||
throw new HttpError(`No scene with ID ${req.params.sceneId} found`, 404);
|
||||
}
|
||||
|
||||
res.send(scene);
|
||||
}
|
||||
|
||||
export async function fetchScenesByIdGraphql(query, req) {
|
||||
const scenes = await fetchScenesById([].concat(query.id, query.ids).filter(Boolean), {
|
||||
reqUser: req.user,
|
||||
@@ -209,3 +227,9 @@ export async function fetchScenesByIdGraphql(query, req) {
|
||||
|
||||
return scenes[0];
|
||||
}
|
||||
|
||||
export async function createSceneRevisionApi(req, res) {
|
||||
await createSceneRevision(Number(req.params.sceneId), req.body, req.user);
|
||||
|
||||
res.status(204).send();
|
||||
}
|
||||
|
||||
@@ -13,7 +13,12 @@ import redis from '../redis.js';
|
||||
import errorHandler from './error.js';
|
||||
import consentHandler from './consent.js';
|
||||
|
||||
import { fetchScenesApi } from './scenes.js';
|
||||
import {
|
||||
fetchScenesApi,
|
||||
fetchSceneApi,
|
||||
createSceneRevisionApi,
|
||||
} from './scenes.js';
|
||||
|
||||
import { fetchActorsApi } from './actors.js';
|
||||
import { fetchMoviesApi } from './movies.js';
|
||||
import { fetchEntitiesApi } from './entities.js';
|
||||
@@ -179,6 +184,8 @@ export default async function initServer() {
|
||||
|
||||
// SCENES
|
||||
router.get('/api/scenes', fetchScenesApi);
|
||||
router.get('/api/scenes/:sceneId', fetchSceneApi);
|
||||
router.patch('/api/scenes/:sceneId', createSceneRevisionApi);
|
||||
|
||||
// ACTORS
|
||||
router.get('/api/actors', fetchActorsApi);
|
||||
|
||||
Reference in New Issue
Block a user