From 3a8a891574c30fcbe972841a023f6212a0fa44a6 Mon Sep 17 00:00:00 2001 From: Julien Constant Date: Tue, 31 Oct 2023 19:50:38 +0100 Subject: [PATCH] fix(core): lint --- README.md | 28 +++++++++++++++------------- src/modules/files/files.service.ts | 7 ++++++- 2 files changed, 21 insertions(+), 14 deletions(-) diff --git a/README.md b/README.md index 9a8884c2..8e246f33 100644 --- a/README.md +++ b/README.md @@ -16,12 +16,12 @@ This repository contains the source code of the API used by the [Sith 4](https:/ ## Table of contents - [Installation](#installation) - - [Project](#project) - - [Environment variables](#environment-variables) - - [Database](#database) - - [PostgreSQL Installation](#postgresql-installation) - - [Configuration](#configuration) - - [First time setup](#first-time-setup) + - [Project](#project) + - [Environment variables](#environment-variables) + - [Database](#database) + - [PostgreSQL Installation](#postgresql-installation) + - [Configuration](#configuration) + - [First time setup](#first-time-setup) - [Launch](#launch) - [Tests](#tests) - [Linting](#linting) @@ -79,13 +79,13 @@ brew services start postgresql@13 # start postgresql service After the installation, you can use [pgAdmin](https://www.pgadmin.org/) to create a server with the following parameters: -| `.env` | pgAdmin 4 | value | -| :------------------: | :------------------: | :---------------------------------------------------------------------------------------- | -| `DB_HOST` | Host | `127.0.0.1` | -| `DB_PORT` | Port | `5432` | -| `DB_USERNAME` | Username | Should be the username you used to install postgresql or any user you have created for it | -| `DB_PASSWORD` | Password | leave it empty, unless you have set a password for your postgresql user | -| `DB_DATABASE` | Maintenance database | `postgres` | +| `.env` | pgAdmin 4 | value | +| :-----------: | :------------------: | :---------------------------------------------------------------------------------------- | +| `DB_HOST` | Host | `127.0.0.1` | +| `DB_PORT` | Port | `5432` | +| `DB_USERNAME` | Username | Should be the username you used to install postgresql or any user you have created for it | +| `DB_PASSWORD` | Password | leave it empty, unless you have set a password for your postgresql user | +| `DB_DATABASE` | Maintenance database | `postgres` | > **Note** > You can also use [TablePlus](https://tableplus.com/) to manage your databases as a lightweight (but more limited, in the free edition) alternative to pgAdmin. @@ -121,6 +121,7 @@ pnpm run start:prod ``` ## Tests + Both unit and e2e tests are available and run with [Jest](https://jestjs.io/). You can run them with the following command: ```bash @@ -131,6 +132,7 @@ pnpm test > After running the tests, a coverage report is generated in the `./coverage` folder. ## Linting + This project uses [ESLint](https://eslint.org/) and [Prettier](https://prettier.io/) to lint the code. You can run the linter with the following command: ```bash diff --git a/src/modules/files/files.service.ts b/src/modules/files/files.service.ts index bdf0a778..3d9ea20a 100644 --- a/src/modules/files/files.service.ts +++ b/src/modules/files/files.service.ts @@ -9,12 +9,15 @@ import { MikroORM, CreateRequestContext, Loaded } from '@mikro-orm/core'; import { BadRequestException, Injectable, NotFoundException } from '@nestjs/common'; import { fromBuffer, MimeType } from 'file-type'; +import { PromotionPicture } from '@modules/promotions/entities/promotion-picture.entity'; import { TranslateService } from '@modules/translate/translate.service'; +import { UserBanner } from '@modules/users/entities/user-banner.entity'; +import { UserPicture } from '@modules/users/entities/user-picture.entity'; import { User } from '@modules/users/entities/user.entity'; import { UsersDataService } from '@modules/users/services/users-data.service'; import { FileVisibilityGroup } from './entities/file-visibility.entity'; -import { File, FileKind } from './entities/file.entity'; +import { File } from './entities/file.entity'; import { ImagesService } from './images.service'; type WriteFileOptions = { @@ -26,6 +29,8 @@ type WriteImageOptions = WriteFileOptions & { aspect_ratio: aspect_ratio; }; +export type FileKind = UserPicture | UserBanner | PromotionPicture; + @Injectable() export class FilesService { constructor(