Added scene chapters to GraphQL. Verifying API credential types.

This commit is contained in:
2026-09-17 01:17:03 +02:00
parent e9b7bb03d0
commit de0b1c2baf
4 changed files with 21 additions and 2 deletions
+8
View File
@@ -628,6 +628,14 @@ export async function verifyKey(userId, key, req) {
throw new HttpError('The API credentials are not provided.', 401);
}
if (typeof userId !== 'number') {
throw new HttpError('User ID is not a number', 400);
}
if (typeof key !== 'string') {
throw new HttpError('Key is not a string', 400);
}
const hashedKey = (await scrypt(key, '', 64)).toString('hex'); // salt redundant for randomly generated key
const storedKey = await knex('users_keys')
+1 -1
View File
@@ -112,7 +112,7 @@ export async function graphqlApi(req, res) {
return;
}
await verifyKey(req.headers['api-user'], req.headers['api-key'], req);
await verifyKey(Number(req.headers['api-user']), req.headers['api-key'], req);
req.user = {
id: Number(req.headers['api-user']),
+11
View File
@@ -131,6 +131,7 @@ export const scenesSchema = `
network: Entity
actors: [Actor!]!
tags: [Tag!]!
chapters: [Chapter!]!
poster: Media
trailer: Media
photos: [Media!]!
@@ -160,6 +161,16 @@ export const scenesSchema = `
size: Int
createdAt: Int
}
type Chapter {
id: Int!
time: Int!
tags: [Tag!]!
date: Date
description: String
title: String
poster: Media
}
`;
function getScope(query) {
+1 -1
View File
@@ -119,7 +119,7 @@ export default async function initServer() {
router.use('/api/{*splat}', async (req, _res, next) => {
if (req.headers['api-user']) {
req.user = await verifyKey(req.headers['api-user'], req.headers['api-key'], req);
req.user = await verifyKey(Number(req.headers['api-user']), req.headers['api-key'], req);
}
next();