Merge tag '13.11.3' into merge-upstream
This commit is contained in:
commit
2911c6a468
87 changed files with 2274 additions and 474 deletions
|
@ -2,6 +2,7 @@ import { dirname } from 'node:path';
|
|||
import { fileURLToPath } from 'node:url';
|
||||
import { randomBytes } from 'node:crypto';
|
||||
import { Inject, Injectable } from '@nestjs/common';
|
||||
import { v4 as uuid } from 'uuid';
|
||||
import { createBullBoard } from '@bull-board/api';
|
||||
import { BullAdapter } from '@bull-board/api/bullAdapter.js';
|
||||
import { FastifyAdapter } from '@bull-board/fastify';
|
||||
|
@ -27,6 +28,7 @@ import { GalleryPostEntityService } from '@/core/entities/GalleryPostEntityServi
|
|||
import { ClipEntityService } from '@/core/entities/ClipEntityService.js';
|
||||
import { ChannelEntityService } from '@/core/entities/ChannelEntityService.js';
|
||||
import type { ChannelsRepository, ClipsRepository, FlashsRepository, GalleryPostsRepository, NotesRepository, PagesRepository, UserProfilesRepository, UsersRepository } from '@/models/index.js';
|
||||
import type Logger from '@/logger.js';
|
||||
import { deepClone } from '@/misc/clone.js';
|
||||
import { bindThis } from '@/decorators.js';
|
||||
import { FlashEntityService } from '@/core/entities/FlashEntityService.js';
|
||||
|
@ -35,6 +37,7 @@ import manifest from './manifest.json' assert { type: 'json' };
|
|||
import { FeedService } from './FeedService.js';
|
||||
import { UrlPreviewService } from './UrlPreviewService.js';
|
||||
import type { FastifyInstance, FastifyPluginOptions, FastifyReply } from 'fastify';
|
||||
import { ClientLoggerService } from './ClientLoggerService.js';
|
||||
|
||||
const _filename = fileURLToPath(import.meta.url);
|
||||
const _dirname = dirname(_filename);
|
||||
|
@ -47,6 +50,8 @@ const viteOut = `${_dirname}/../../../../../built/_vite_/`;
|
|||
|
||||
@Injectable()
|
||||
export class ClientServerService {
|
||||
private logger: Logger;
|
||||
|
||||
constructor(
|
||||
@Inject(DI.config)
|
||||
private config: Config,
|
||||
|
@ -86,6 +91,7 @@ export class ClientServerService {
|
|||
private urlPreviewService: UrlPreviewService,
|
||||
private feedService: FeedService,
|
||||
private roleService: RoleService,
|
||||
private clientLoggerService: ClientLoggerService,
|
||||
|
||||
@Inject('queue:system') public systemQueue: SystemQueue,
|
||||
@Inject('queue:endedPollNotification') public endedPollNotificationQueue: EndedPollNotificationQueue,
|
||||
|
@ -663,6 +669,24 @@ export class ClientServerService {
|
|||
return await renderBase(reply);
|
||||
});
|
||||
|
||||
fastify.setErrorHandler(async (error, request, reply) => {
|
||||
const errId = uuid();
|
||||
this.clientLoggerService.logger.error(`Internal error occured in ${request.routerPath}: ${error.message}`, {
|
||||
path: request.routerPath,
|
||||
params: request.params,
|
||||
query: request.query,
|
||||
code: error.name,
|
||||
stack: error.stack,
|
||||
id: errId,
|
||||
});
|
||||
reply.code(500);
|
||||
reply.header('Cache-Control', 'max-age=10, must-revalidate');
|
||||
return await reply.view('error', {
|
||||
code: error.code,
|
||||
id: errId,
|
||||
});
|
||||
});
|
||||
|
||||
done();
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue