chore(dependencies): update TypeScript ESLint and Vitest to latest versions

- Bump @typescript-eslint packages to 8.23.0
- Update Vitest and related packages to 2.1.9
- Minor version upgrades for ts-api-utils and other related dependencies
This commit is contained in:
Amruth Pillai
2025-02-03 19:51:39 +01:00
parent ec4e43d4fc
commit 7054623678
10 changed files with 277 additions and 179 deletions

View File

@ -26,7 +26,7 @@ export class GitHubStrategy extends PassportStrategy(Strategy, "github") {
) {
const { displayName, emails, photos, username } = profile;
const email = emails?.[0].value ?? `${username}@github.com`;
const email = (emails?.[0].value ?? `${username}@github.com`).toLocaleLowerCase();
const picture = photos?.[0].value;
let user: User | null = null;

View File

@ -26,7 +26,7 @@ export class GoogleStrategy extends PassportStrategy(Strategy, "google") {
) {
const { displayName, emails, photos, username } = profile;
const email = emails?.[0].value ?? `${username}@google.com`;
const email = (emails?.[0].value ?? `${username}@google.com`).toLocaleLowerCase();
const picture = photos?.[0].value;
let user: User | null = null;

View File

@ -39,7 +39,7 @@ export class OpenIDStrategy extends PassportStrategy(Strategy, "openid") {
const { displayName, emails, photos, username } = profile;
const uniqueId = generateRandomName({ length: 2, style: "lowerCase", separator: "-" });
const email = emails?.[0].value ?? `${username ?? uniqueId}@openid.com`;
const email = (emails?.[0].value ?? `${username ?? uniqueId}@openid.com`).toLocaleLowerCase();
const picture = photos?.[0].value;
let user: User | null = null;

View File

@ -99,7 +99,7 @@ export class StorageService implements OnModuleInit {
}
}
async bucketExists() {
async bucketExists(): Promise<true> {
const exists = await this.client.bucketExists(this.bucketName);
if (!exists) {
@ -107,6 +107,8 @@ export class StorageService implements OnModuleInit {
"There was an error while checking if the storage bucket exists.",
);
}
return exists;
}
async uploadObject(
@ -114,7 +116,7 @@ export class StorageService implements OnModuleInit {
type: UploadType,
buffer: Buffer,
filename: string = createId(),
) {
): Promise<string> {
const extension = type === "resumes" ? "pdf" : "jpg";
const storageUrl = this.configService.getOrThrow<string>("STORAGE_URL");
@ -149,13 +151,12 @@ export class StorageService implements OnModuleInit {
}
}
async deleteObject(userId: string, type: UploadType, filename: string) {
async deleteObject(userId: string, type: UploadType, filename: string): Promise<void> {
const extension = type === "resumes" ? "pdf" : "jpg";
const path = `${userId}/${type}/${filename}.${extension}`;
try {
await this.client.removeObject(this.bucketName, path);
return;
} catch {
throw new InternalServerErrorException(
`There was an error while deleting the document at the specified path: ${path}.`,
@ -163,9 +164,8 @@ export class StorageService implements OnModuleInit {
}
}
async deleteFolder(prefix: string) {
async deleteFolder(prefix: string): Promise<void> {
const objectsList = [];
const objectsStream = this.client.listObjectsV2(this.bucketName, prefix, true);
for await (const object of objectsStream) {
@ -174,7 +174,6 @@ export class StorageService implements OnModuleInit {
try {
await this.client.removeObjects(this.bucketName, objectsList);
return;
} catch {
throw new InternalServerErrorException(
`There was an error while deleting the folder at the specified path: ${this.bucketName}/${prefix}.`,

View File

@ -1,5 +1,6 @@
import { Injectable, InternalServerErrorException } from "@nestjs/common";
import { Prisma } from "@prisma/client";
import { Prisma, User } from "@prisma/client";
import { UserWithSecrets } from "@reactive-resume/dto";
import { ErrorMessage } from "@reactive-resume/utils";
import { PrismaService } from "nestjs-prisma";
@ -12,7 +13,7 @@ export class UserService {
private readonly storageService: StorageService,
) {}
async findOneById(id: string) {
async findOneById(id: string): Promise<UserWithSecrets> {
const user = await this.prisma.user.findUniqueOrThrow({
where: { id },
include: { secrets: true },
@ -25,7 +26,7 @@ export class UserService {
return user;
}
async findOneByIdentifier(identifier: string) {
async findOneByIdentifier(identifier: string): Promise<UserWithSecrets | null> {
const user = await (async (identifier: string) => {
// First, find the user by email
const user = await this.prisma.user.findUnique({
@ -47,7 +48,7 @@ export class UserService {
return user;
}
async findOneByIdentifierOrThrow(identifier: string) {
async findOneByIdentifierOrThrow(identifier: string): Promise<UserWithSecrets> {
const user = await (async (identifier: string) => {
// First, find the user by email
const user = await this.prisma.user.findUnique({
@ -69,21 +70,25 @@ export class UserService {
return user;
}
create(data: Prisma.UserCreateInput) {
create(data: Prisma.UserCreateInput): Promise<UserWithSecrets> {
return this.prisma.user.create({ data, include: { secrets: true } });
}
updateByEmail(email: string, data: Prisma.UserUpdateArgs["data"]) {
updateByEmail(email: string, data: Prisma.UserUpdateArgs["data"]): Promise<User> {
return this.prisma.user.update({ where: { email }, data });
}
async updateByResetToken(resetToken: string, data: Prisma.SecretsUpdateArgs["data"]) {
async updateByResetToken(
resetToken: string,
data: Prisma.SecretsUpdateArgs["data"],
): Promise<void> {
await this.prisma.secrets.update({ where: { resetToken }, data });
}
async deleteOneById(id: string) {
await this.storageService.deleteFolder(id);
return this.prisma.user.delete({ where: { id } });
async deleteOneById(id: string): Promise<void> {
await Promise.all([
this.storageService.deleteFolder(id),
this.prisma.user.delete({ where: { id } }),
]);
}
}