Merge branch 'dev' into boards
Some checks failed
Node.js CI / build (postgresql, 18.18, 10) (push) Has been cancelled

# Conflicts:
#	pnpm-lock.yaml
This commit is contained in:
Mike Cao 2025-12-04 00:53:54 -08:00
commit 5ce1b40330
93 changed files with 3153 additions and 1340 deletions

View file

@ -7,7 +7,7 @@ import { checkPassword } from '@/lib/password';
import redis from '@/lib/redis';
import { parseRequest } from '@/lib/request';
import { json, unauthorized } from '@/lib/response';
import { getUserByUsername } from '@/queries/prisma';
import { getAllUserTeams, getUserByUsername } from '@/queries/prisma';
export async function POST(request: Request) {
const schema = z.object({
@ -39,8 +39,10 @@ export async function POST(request: Request) {
token = createSecureToken({ userId: user.id, role }, secret());
}
const teams = await getAllUserTeams(id);
return json({
token,
user: { id, username, role, createdAt, isAdmin: role === ROLES.admin },
user: { id, username, role, createdAt, isAdmin: role === ROLES.admin, teams },
});
}

View file

@ -17,6 +17,7 @@ export async function POST(request: Request) {
const errors = [];
let index = 0;
let cache = null;
for (const data of body) {
// Recreate a fresh Request since `new Request(request)` will have the following error:
// > Cannot read private member #state from an object whose class did not declare it
@ -33,9 +34,12 @@ export async function POST(request: Request) {
});
const response = await send.POST(newRequest);
const responseJson = await response.json();
if (!response.ok) {
errors.push({ index, response: await response.json() });
errors.push({ index, response: responseJson });
} else {
cache ??= responseJson.cache;
}
index++;
@ -46,6 +50,7 @@ export async function POST(request: Request) {
processed: body.length - errors.length,
errors: errors.length,
details: errors,
cache,
});
} catch (e) {
return serverError(e);

View file

@ -41,6 +41,9 @@ const schema = z.object({
userAgent: z.string().optional(),
timestamp: z.coerce.number().int().optional(),
id: z.string().optional(),
browser: z.string().optional(),
os: z.string().optional(),
device: z.string().optional(),
})
.refine(
data => {