add prettifier

This commit is contained in:
philipredstone
2025-04-15 14:46:06 +02:00
parent c078610c4d
commit eceacf2117
43 changed files with 10946 additions and 6173 deletions

View File

@ -1,33 +1,37 @@
import { Response, NextFunction } from 'express';
import Network from '../models/network.model';
import { UserRequest } from '../types/express';
export const checkNetworkAccess = async (req: UserRequest, res: Response, next: NextFunction): Promise<void> => {
try {
const networkId = req.params.networkId;
if (!networkId) {
res.status(400).json({ message: 'Network ID is required' });
return;
}
const network = await Network.findById(networkId);
if (!network) {
res.status(404).json({ message: 'Network not found' });
return;
}
// Check if user is the owner or the network is public
if (network.owner.toString() !== req.user?._id.toString() && !network.isPublic) {
res.status(403).json({ message: 'You do not have permission to access this network' });
return;
}
// Add network to the request
req.network = network;
next();
} catch (error) {
res.status(500).json({ message: 'Server error' });
}
};
import { Response, NextFunction } from 'express';
import Network from '../models/network.model';
import { UserRequest } from '../types/express';
export const checkNetworkAccess = async (
req: UserRequest,
res: Response,
next: NextFunction
): Promise<void> => {
try {
const networkId = req.params.networkId;
if (!networkId) {
res.status(400).json({ message: 'Network ID is required' });
return;
}
const network = await Network.findById(networkId);
if (!network) {
res.status(404).json({ message: 'Network not found' });
return;
}
// Check if user is the owner or the network is public
if (network.owner.toString() !== req.user?._id.toString() && !network.isPublic) {
res.status(403).json({ message: 'You do not have permission to access this network' });
return;
}
// Add network to the request
req.network = network;
next();
} catch (error) {
res.status(500).json({ message: 'Server error' });
}
};