mirror of https://github.com/AlphaNecron/Void.git
fix(api,docker): try catch for discord logger
This commit is contained in:
parent
6e7aa89041
commit
e977d066a1
|
@ -2,11 +2,11 @@ version: '3'
|
|||
services:
|
||||
postgres:
|
||||
image: postgres
|
||||
environment:
|
||||
environment:
|
||||
- POSTGRES_USER=postgres
|
||||
- POSTGRES_PASSWORD=postgres
|
||||
- POSTGRES_DATABASE=postgres
|
||||
volumes:
|
||||
volumes:
|
||||
- pg_data:/var/lib/postgresql/data
|
||||
healthcheck:
|
||||
test: ['CMD-SHELL', 'pg_isready -U postgres']
|
||||
|
@ -19,9 +19,9 @@ services:
|
|||
- '3000:3000'
|
||||
restart: unless-stopped
|
||||
volumes:
|
||||
- '$PWD/uploads:/void/uploads'
|
||||
- '$PWD/public:/void/public'
|
||||
- '$PWD/config.toml:/void/config.toml'
|
||||
- './uploads:/void/uploads'
|
||||
- './public:/void/public'
|
||||
- './config.toml:/void/config.toml'
|
||||
depends_on:
|
||||
- 'postgres'
|
||||
volumes:
|
||||
|
|
|
@ -37,10 +37,13 @@ async function handler(req: NextApiReq, res: NextApiRes) {
|
|||
}
|
||||
});
|
||||
info('URL', `User ${user.username} (${user.id}) shortened a URL: ${url.destination} (${url.id})`);
|
||||
try {
|
||||
global.logger.logUrl(url, user.username);
|
||||
}
|
||||
catch {}
|
||||
return res.json({
|
||||
url: `http${config.core.secure ? 's' : ''}://${req.headers.host}${config.shortener.route}/${url.short}`
|
||||
});
|
||||
}
|
||||
|
||||
export default withVoid(handler);
|
||||
export default withVoid(handler);
|
||||
|
|
|
@ -49,7 +49,10 @@ async function handler(req: NextApiReq, res: NextApiRes) {
|
|||
});
|
||||
await writeFile(join(process.cwd(), cfg.uploader.directory, file.fileName), req.file.buffer);
|
||||
info('FILE', `User ${user.username} (${user.id}) uploaded a file: ${file.fileName} (${file.id})`);
|
||||
global.logger.logFile(file, user.username);
|
||||
try {
|
||||
global.logger.logFile(file, user.username);
|
||||
}
|
||||
catch {}
|
||||
const baseUrl = `http${cfg.core.secure ? 's' : ''}://${req.headers.host}`;
|
||||
return res.json({
|
||||
url: `${baseUrl}/${file.slug}`,
|
||||
|
@ -77,4 +80,4 @@ export const config = {
|
|||
api: {
|
||||
bodyParser: false,
|
||||
},
|
||||
};
|
||||
};
|
||||
|
|
|
@ -20,7 +20,7 @@ async function handler(req: NextApiReq, res: NextApiRes) {
|
|||
username: req.body.username
|
||||
}
|
||||
});
|
||||
if (existing && user.username !== req.body.username) {
|
||||
if (existing && user.username !== req.body.username) {
|
||||
return res.forbid('Username is already taken');
|
||||
}
|
||||
await prisma.user.update({
|
||||
|
@ -74,4 +74,4 @@ async function handler(req: NextApiReq, res: NextApiRes) {
|
|||
}
|
||||
}
|
||||
|
||||
export default withVoid(handler);
|
||||
export default withVoid(handler);
|
||||
|
|
|
@ -22,7 +22,10 @@ async function handler(req: NextApiReq, res: NextApiRes) {
|
|||
});
|
||||
delete userToDelete.password;
|
||||
info('USER', `Deleted user ${userToDelete.username} (${userToDelete.id})`);
|
||||
global.logger.logUser('delete', userToDelete);
|
||||
try {
|
||||
global.logger.logUser('delete', userToDelete);
|
||||
}
|
||||
catch {}
|
||||
return res.json(userToDelete);
|
||||
} else if (req.method === 'POST') {
|
||||
const { username, password, isAdmin } = req.body as { username: string, password: string, isAdmin: boolean };
|
||||
|
@ -45,7 +48,10 @@ async function handler(req: NextApiReq, res: NextApiRes) {
|
|||
});
|
||||
delete newUser.password;
|
||||
info('USER', `Created user ${newUser.username} (${newUser.id})`);
|
||||
global.logger.logUser('create', newUser);
|
||||
try {
|
||||
global.logger.logUser('create', newUser);
|
||||
}
|
||||
catch {}
|
||||
return res.json(newUser);
|
||||
} else {
|
||||
const all = await prisma.user.findMany({
|
||||
|
@ -65,4 +71,4 @@ async function handler(req: NextApiReq, res: NextApiRes) {
|
|||
}
|
||||
}
|
||||
|
||||
export default withVoid(handler);
|
||||
export default withVoid(handler);
|
||||
|
|
Loading…
Reference in New Issue