Skip to content

Commit 9c2148e

Browse files
committed
Standardize import statements and improve error handling in ImagesService: Updated import syntax to use single quotes for consistency, enhanced error messages for clarity, and ensured proper formatting throughout the file.
1 parent de26e73 commit 9c2148e

File tree

2 files changed

+48
-52
lines changed

2 files changed

+48
-52
lines changed

apps/api/src/storage/images.service.ts

Lines changed: 10 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
1-
import { BadRequestException, Injectable } from "@nestjs/common";
2-
import sharp from "sharp";
3-
import { FilesService } from "./files.service";
1+
import { BadRequestException, Injectable } from '@nestjs/common';
2+
import sharp from 'sharp';
3+
import { FilesService } from './files.service';
44

55
@Injectable()
66
export class ImagesService {
7-
private static readonly allowedFormats = new Set(["jpeg", "png", "webp"]);
7+
private static readonly allowedFormats = new Set(['jpeg', 'png', 'webp']);
88
private static readonly mimeTypeByFormat: Record<string, string> = {
9-
jpeg: "image/jpeg",
10-
png: "image/png",
11-
webp: "image/webp"
9+
jpeg: 'image/jpeg',
10+
png: 'image/png',
11+
webp: 'image/webp',
1212
};
1313

1414
constructor(private readonly filesService: FilesService) {}
@@ -30,7 +30,7 @@ export class ImagesService {
3030

3131
private async assertValidImage(file: Express.Multer.File) {
3232
if (!file.buffer.length) {
33-
throw new BadRequestException("Uploaded file is empty.");
33+
throw new BadRequestException('Uploaded file is empty.');
3434
}
3535

3636
const metadata = await sharp(file.buffer)
@@ -39,16 +39,12 @@ export class ImagesService {
3939
const format = metadata?.format;
4040

4141
if (!format || !ImagesService.allowedFormats.has(format)) {
42-
throw new BadRequestException(
43-
"Uploaded file must be a valid JPEG, PNG, or WEBP image."
44-
);
42+
throw new BadRequestException('Uploaded file must be a valid JPEG, PNG, or WEBP image.');
4543
}
4644

4745
const expectedMimeType = ImagesService.mimeTypeByFormat[format];
4846
if (file.mimetype !== expectedMimeType) {
49-
throw new BadRequestException(
50-
"File content does not match the provided MIME type."
51-
);
47+
throw new BadRequestException('File content does not match the provided MIME type.');
5248
}
5349
}
5450
}

apps/web/src/routeTree.gen.ts

Lines changed: 38 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -8,79 +8,79 @@
88
// You should NOT make any changes in this file as it will be overwritten.
99
// Additionally, you should also exclude this file from your linter and/or formatter to prevent it from being checked or modified.
1010

11-
import { Route as rootRouteImport } from './routes/__root'
12-
import { Route as LoginRouteImport } from './routes/login'
13-
import { Route as IndexRouteImport } from './routes/index'
11+
import { Route as rootRouteImport } from './routes/__root';
12+
import { Route as LoginRouteImport } from './routes/login';
13+
import { Route as IndexRouteImport } from './routes/index';
1414

1515
const LoginRoute = LoginRouteImport.update({
1616
id: '/login',
1717
path: '/login',
1818
getParentRoute: () => rootRouteImport,
19-
} as any)
19+
} as any);
2020
const IndexRoute = IndexRouteImport.update({
2121
id: '/',
2222
path: '/',
2323
getParentRoute: () => rootRouteImport,
24-
} as any)
24+
} as any);
2525

2626
export interface FileRoutesByFullPath {
27-
'/': typeof IndexRoute
28-
'/login': typeof LoginRoute
27+
'/': typeof IndexRoute;
28+
'/login': typeof LoginRoute;
2929
}
3030
export interface FileRoutesByTo {
31-
'/': typeof IndexRoute
32-
'/login': typeof LoginRoute
31+
'/': typeof IndexRoute;
32+
'/login': typeof LoginRoute;
3333
}
3434
export interface FileRoutesById {
35-
__root__: typeof rootRouteImport
36-
'/': typeof IndexRoute
37-
'/login': typeof LoginRoute
35+
__root__: typeof rootRouteImport;
36+
'/': typeof IndexRoute;
37+
'/login': typeof LoginRoute;
3838
}
3939
export interface FileRouteTypes {
40-
fileRoutesByFullPath: FileRoutesByFullPath
41-
fullPaths: '/' | '/login'
42-
fileRoutesByTo: FileRoutesByTo
43-
to: '/' | '/login'
44-
id: '__root__' | '/' | '/login'
45-
fileRoutesById: FileRoutesById
40+
fileRoutesByFullPath: FileRoutesByFullPath;
41+
fullPaths: '/' | '/login';
42+
fileRoutesByTo: FileRoutesByTo;
43+
to: '/' | '/login';
44+
id: '__root__' | '/' | '/login';
45+
fileRoutesById: FileRoutesById;
4646
}
4747
export interface RootRouteChildren {
48-
IndexRoute: typeof IndexRoute
49-
LoginRoute: typeof LoginRoute
48+
IndexRoute: typeof IndexRoute;
49+
LoginRoute: typeof LoginRoute;
5050
}
5151

5252
declare module '@tanstack/react-router' {
5353
interface FileRoutesByPath {
5454
'/login': {
55-
id: '/login'
56-
path: '/login'
57-
fullPath: '/login'
58-
preLoaderRoute: typeof LoginRouteImport
59-
parentRoute: typeof rootRouteImport
60-
}
55+
id: '/login';
56+
path: '/login';
57+
fullPath: '/login';
58+
preLoaderRoute: typeof LoginRouteImport;
59+
parentRoute: typeof rootRouteImport;
60+
};
6161
'/': {
62-
id: '/'
63-
path: '/'
64-
fullPath: '/'
65-
preLoaderRoute: typeof IndexRouteImport
66-
parentRoute: typeof rootRouteImport
67-
}
62+
id: '/';
63+
path: '/';
64+
fullPath: '/';
65+
preLoaderRoute: typeof IndexRouteImport;
66+
parentRoute: typeof rootRouteImport;
67+
};
6868
}
6969
}
7070

7171
const rootRouteChildren: RootRouteChildren = {
7272
IndexRoute: IndexRoute,
7373
LoginRoute: LoginRoute,
74-
}
74+
};
7575
export const routeTree = rootRouteImport
7676
._addFileChildren(rootRouteChildren)
77-
._addFileTypes<FileRouteTypes>()
77+
._addFileTypes<FileRouteTypes>();
7878

79-
import type { getRouter } from './router.tsx'
80-
import type { createStart } from '@tanstack/react-start'
79+
import type { getRouter } from './router.tsx';
80+
import type { createStart } from '@tanstack/react-start';
8181
declare module '@tanstack/react-start' {
8282
interface Register {
83-
ssr: true
84-
router: Awaited<ReturnType<typeof getRouter>>
83+
ssr: true;
84+
router: Awaited<ReturnType<typeof getRouter>>;
8585
}
8686
}

0 commit comments

Comments
 (0)