allow anon requests
Some checks failed
ci / build (push) Failing after 0s
ci / Tests & Checks (push) Failing after 2s

This commit is contained in:
CJ_Clippy 2025-06-17 07:21:07 -08:00
parent 330e38db75
commit 07deb092e8
2 changed files with 31 additions and 38 deletions

View File

@ -29,55 +29,51 @@ export default async function vodsRoutes(
fastify: FastifyInstance,
): Promise<void> {
fastify.get('/vods', async function (request, reply) {
const userId = request.session.get('userId')
let user = await prisma.user.findFirstOrThrow({
where: {
id: userId
},
include: {
roles: true
}
})
const userId = request.session.get('userId');
let user = null
if (userId !== undefined) {
user = await prisma.user.findUnique({
where: { id: userId },
include: { roles: true }
})
}
const { cursor: cursorRaw, search = '' } = request.query as {
cursor?: string; // query strings are strings
cursor?: string;
search?: string;
};
const cursor = cursorRaw ? parseInt(cursorRaw, 10) : undefined;
// if (!cursor) throw new Error('cursor missing'); // is this necessary?
if (cursorRaw && isNaN(cursor)) {
return reply.status(400).send({ error: 'Invalid cursor value' });
}
const vods = await prisma.vod.findMany({
where: search ? {
status: 'processed',
name: {
contains: search,
mode: 'insensitive',
},
} : {
where: {
status: {
in: [
'approved', 'processed', 'processing'
]
}
in: ['approved', 'processed', 'processing'],
},
},
orderBy: { createdAt: 'desc' },
include: {
vtubers: true,
stream: true
}
stream: true,
},
});
return reply.viewAsync('vods.hbs', {
user,
vods,
site: constants.site
site: constants.site,
});
});
fastify.get('/vods/:id', async function (request, reply) {
const { id } = request.params as { id: string };

View File

@ -18,23 +18,19 @@ export default async function vtubersRoutes(
fastify.get('/vtubers', async function (request, reply) {
const userId = request.session.get('userId')
let user = await prisma.user.findFirstOrThrow({
where: {
id: userId
},
include: {
roles: true
}
})
console.log(`userId=${userId}`)
let user = null
if (userId !== undefined) {
user = await prisma.user.findUnique({
where: { id: userId },
include: { roles: true }
})
}
const vtubers = await prisma.vtuber.findMany({
orderBy: { createdAt: 'desc' },
include: {
vods: true,
// streams: true
}
include: { vods: true }
});
return reply.viewAsync('vtubers/list.hbs', {
@ -44,6 +40,7 @@ export default async function vtubersRoutes(
});
});
fastify.get('/vtubers/new', async function (request, reply) {
const userId = request.session.get('userId');