refactor(backend): Improve UUID generation (#11286)
* Replace with `crypto.randomUUID()` * Remove uuid
This commit is contained in:
parent
9d5dd7201e
commit
b392f44b81
9 changed files with 25 additions and 34 deletions
|
@ -1,8 +1,8 @@
|
|||
import { randomUUID } from 'node:crypto';
|
||||
import { pipeline } from 'node:stream';
|
||||
import * as fs from 'node:fs';
|
||||
import { promisify } from 'node:util';
|
||||
import { Inject, Injectable } from '@nestjs/common';
|
||||
import { v4 as uuid } from 'uuid';
|
||||
import { DI } from '@/di-symbols.js';
|
||||
import { getIpHash } from '@/misc/get-ip-hash.js';
|
||||
import type { LocalUser, User } from '@/models/entities/User.js';
|
||||
|
@ -362,7 +362,7 @@ export class ApiCallService implements OnApplicationShutdown {
|
|||
if (err instanceof ApiError || err instanceof AuthenticationError) {
|
||||
throw err;
|
||||
} else {
|
||||
const errId = uuid();
|
||||
const errId = randomUUID();
|
||||
this.logger.error(`Internal error occurred in ${ep.name}: ${err.message}`, {
|
||||
ep: ep.name,
|
||||
ps: data,
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import { v4 as uuid } from 'uuid';
|
||||
import { randomUUID } from 'node:crypto';
|
||||
import { Inject, Injectable } from '@nestjs/common';
|
||||
import { Endpoint } from '@/server/api/endpoint-base.js';
|
||||
import type { AppsRepository, AuthSessionsRepository } from '@/models/index.js';
|
||||
|
@ -71,7 +71,7 @@ export default class extends Endpoint<typeof meta, typeof paramDef> {
|
|||
}
|
||||
|
||||
// Generate token
|
||||
const token = uuid();
|
||||
const token = randomUUID();
|
||||
|
||||
// Create session token document
|
||||
const doc = await this.authSessionsRepository.insert({
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
import { randomUUID } from 'node:crypto';
|
||||
import { dirname } from 'node:path';
|
||||
import { fileURLToPath } from 'node:url';
|
||||
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';
|
||||
|
@ -676,7 +676,7 @@ export class ClientServerService {
|
|||
});
|
||||
|
||||
fastify.setErrorHandler(async (error, request, reply) => {
|
||||
const errId = uuid();
|
||||
const errId = randomUUID();
|
||||
this.clientLoggerService.logger.error(`Internal error occured in ${request.routerPath}: ${error.message}`, {
|
||||
path: request.routerPath,
|
||||
params: request.params,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue