|
@@ -3,7 +3,7 @@ import bcrypt from 'bcryptjs';
|
|
|
import multer from 'multer';
|
|
import multer from 'multer';
|
|
|
import path from 'path';
|
|
import path from 'path';
|
|
|
import { v4 as uuidv4 } from 'uuid';
|
|
import { v4 as uuidv4 } from 'uuid';
|
|
|
-import { prisma } from '../lib/prisma';
|
|
|
|
|
|
|
+import { prisma, bigintToNumber } from '../lib/prisma';
|
|
|
import { authMiddleware } from '../lib/auth';
|
|
import { authMiddleware } from '../lib/auth';
|
|
|
|
|
|
|
|
const router = Router();
|
|
const router = Router();
|
|
@@ -62,13 +62,13 @@ router.get('/', async (req: Request, res: Response) => {
|
|
|
const usersWithStorage = users.map(u => ({
|
|
const usersWithStorage = users.map(u => ({
|
|
|
...u,
|
|
...u,
|
|
|
storageUsed: u.projects.reduce(
|
|
storageUsed: u.projects.reduce(
|
|
|
- (sum, p) => sum + p.assets.reduce((s, a) => s + a.fileSize, 0),
|
|
|
|
|
|
|
+ (sum, p) => sum + p.assets.reduce((s, a) => s + Number(a.fileSize), 0),
|
|
|
0
|
|
0
|
|
|
),
|
|
),
|
|
|
ownedProjects: u.projects.length,
|
|
ownedProjects: u.projects.length,
|
|
|
}));
|
|
}));
|
|
|
|
|
|
|
|
- res.json({ users: usersWithStorage });
|
|
|
|
|
|
|
+ res.json({ users: usersWithStorage.map(bigintToNumber) });
|
|
|
} catch (err) {
|
|
} catch (err) {
|
|
|
console.error('List users error:', err);
|
|
console.error('List users error:', err);
|
|
|
res.status(500).json({ error: 'Internal server error' });
|
|
res.status(500).json({ error: 'Internal server error' });
|
|
@@ -146,11 +146,7 @@ router.put('/:id/quota', async (req: Request, res: Response) => {
|
|
|
});
|
|
});
|
|
|
|
|
|
|
|
res.json({
|
|
res.json({
|
|
|
- user: {
|
|
|
|
|
- ...user,
|
|
|
|
|
- storageQuota,
|
|
|
|
|
- storageUsed: user.storageUsed ?? 0,
|
|
|
|
|
- },
|
|
|
|
|
|
|
+ user: bigintToNumber({ ...user, storageQuota, storageUsed: user.storageUsed ?? BigInt(0) }),
|
|
|
});
|
|
});
|
|
|
} catch (err) {
|
|
} catch (err) {
|
|
|
console.error('Update quota error:', err);
|
|
console.error('Update quota error:', err);
|