diff --git a/.github/ISSUE_TEMPLATE/bug_report.yml b/.github/ISSUE_TEMPLATE/bug_report.yml index f166041..26f3a9a 100644 --- a/.github/ISSUE_TEMPLATE/bug_report.yml +++ b/.github/ISSUE_TEMPLATE/bug_report.yml @@ -1,41 +1,41 @@ -name: "Bug Report" -description: "Сообщить об ошибке в работе приложения" -labels: ["bug", "triage"] +name: 'Bug Report' +description: 'Сообщить об ошибке в работе приложения' +labels: ['bug', 'triage'] body: - - type: markdown - attributes: - value: | - Спасибо, что решили помочь сделать проект лучше! - - type: input - id: version - attributes: - label: "Версия приложения" - description: "Какую версию вы используете? (например, 0.0.1)" - placeholder: "0.0.x" - validations: - required: true - - type: textarea - id: steps - attributes: - label: "Шаги воспроизведения" - description: "Как нам увидеть эту ошибку?" - placeholder: | - 1. Запустить docker-compose - 2. Отправить POST запрос на /api/v1/auth... - validations: - required: true - - type: dropdown - id: environment - attributes: - label: "Окружение" - options: - - Docker - - Local (pnpm) - - Production - validations: - required: true - - type: textarea - id: expected - attributes: - label: "Ожидаемое поведение" - placeholder: "Что должно было произойти?" \ No newline at end of file + - type: markdown + attributes: + value: | + Спасибо, что решили помочь сделать проект лучше! + - type: input + id: version + attributes: + label: 'Версия приложения' + description: 'Какую версию вы используете? (например, 0.0.1)' + placeholder: '0.0.x' + validations: + required: true + - type: textarea + id: steps + attributes: + label: 'Шаги воспроизведения' + description: 'Как нам увидеть эту ошибку?' + placeholder: | + 1. Запустить docker-compose + 2. Отправить POST запрос на /api/v1/auth... + validations: + required: true + - type: dropdown + id: environment + attributes: + label: 'Окружение' + options: + - Docker + - Local (pnpm) + - Production + validations: + required: true + - type: textarea + id: expected + attributes: + label: 'Ожидаемое поведение' + placeholder: 'Что должно было произойти?' diff --git a/.github/ISSUE_TEMPLATE/config.yml b/.github/ISSUE_TEMPLATE/config.yml index 656e5e5..c6c9292 100644 --- a/.github/ISSUE_TEMPLATE/config.yml +++ b/.github/ISSUE_TEMPLATE/config.yml @@ -1,10 +1,10 @@ blank_issues_enabled: false contact_links: - - name: "❓ Вопросы по использованию" - url: "https://github.com/Task-Tracker-Lab/task-tracker-backend/discussions/new?category=q-a" - about: "Если вы не уверены, баг это или нет, или вам нужна помощь в настройке — спросите здесь." + - name: '❓ Вопросы по использованию' + url: 'https://github.com/Task-Tracker-Lab/task-tracker-backend/discussions/new?category=q-a' + about: 'Если вы не уверены, баг это или нет, или вам нужна помощь в настройке — спросите здесь.' - - name: "💡 Идеи и предложения" - url: "https://github.com/Task-Tracker-Lab/task-tracker-backend/discussions/new?category=ideas" - about: "Хотите обсудить новую крутую фичу перед тем, как заводить задачу? Вам сюда." \ No newline at end of file + - name: '💡 Идеи и предложения' + url: 'https://github.com/Task-Tracker-Lab/task-tracker-backend/discussions/new?category=ideas' + about: 'Хотите обсудить новую крутую фичу перед тем, как заводить задачу? Вам сюда.' diff --git a/.github/ISSUE_TEMPLATE/feature_request.yml b/.github/ISSUE_TEMPLATE/feature_request.yml index 4c6bacc..c90da45 100644 --- a/.github/ISSUE_TEMPLATE/feature_request.yml +++ b/.github/ISSUE_TEMPLATE/feature_request.yml @@ -1,18 +1,18 @@ -name: "🚀 Feature Request" -description: "Предложить новую идею или улучшение" -labels: ["enhancement"] +name: '🚀 Feature Request' +description: 'Предложить новую идею или улучшение' +labels: ['enhancement'] body: - - type: textarea - id: problem - attributes: - label: "Какую проблему мы решаем?" - description: "Опишите, почему текущего функционала недостаточно." - validations: - required: true - - type: textarea - id: solution - attributes: - label: "Ваше предложение" - description: "Как именно вы видите реализацию этой фичи?" - validations: - required: true \ No newline at end of file + - type: textarea + id: problem + attributes: + label: 'Какую проблему мы решаем?' + description: 'Опишите, почему текущего функционала недостаточно.' + validations: + required: true + - type: textarea + id: solution + attributes: + label: 'Ваше предложение' + description: 'Как именно вы видите реализацию этой фичи?' + validations: + required: true diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index aa9a576..3034e40 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -1,37 +1,37 @@ name: CI on: - pull_request: - branches: [dev, main] - push: - branches: [dev, main] + pull_request: + branches: [dev, main] + push: + branches: [dev, main] jobs: - quality-check: - name: Lint & Test - runs-on: ubuntu-latest + quality-check: + name: Lint & Test + runs-on: ubuntu-latest - steps: - - name: Checkout repository - uses: actions/checkout@v4 + steps: + - name: Checkout repository + uses: actions/checkout@v4 - - name: Install pnpm - uses: pnpm/action-setup@v4 + - name: Install pnpm + uses: pnpm/action-setup@v4 - - name: Setup Node.js - uses: actions/setup-node@v4 - with: - node-version: 20 - cache: "pnpm" + - name: Setup Node.js + uses: actions/setup-node@v4 + with: + node-version: 20 + cache: 'pnpm' - - name: Install dependencies - run: pnpm install --frozen-lockfile + - name: Install dependencies + run: pnpm install --frozen-lockfile - - name: Run Lint - run: pnpm run lint + - name: Run Lint + run: pnpm run lint - - name: Type Check - run: pnpm exec tsc --noEmit + - name: Type Check + run: pnpm exec tsc --noEmit - - name: Run Tests - run: pnpm run test + - name: Run Tests + run: pnpm run test diff --git a/.github/workflows/codeql.yml b/.github/workflows/codeql.yml index c168cd6..129d47e 100644 --- a/.github/workflows/codeql.yml +++ b/.github/workflows/codeql.yml @@ -1,4 +1,4 @@ -name: "CodeQL" +name: 'CodeQL' on: push: @@ -6,7 +6,7 @@ on: pull_request: branches: [main] schedule: - - cron: "15 13 * * 5" + - cron: '15 13 * * 5' jobs: analyze: diff --git a/.github/workflows/stale.yml b/.github/workflows/stale.yml index fbc62d1..f812282 100644 --- a/.github/workflows/stale.yml +++ b/.github/workflows/stale.yml @@ -1,8 +1,8 @@ -name: "Close stale issues and PRs" +name: 'Close stale issues and PRs' on: schedule: - - cron: "30 1 * * *" + - cron: '30 1 * * *' jobs: stale: @@ -13,7 +13,7 @@ jobs: steps: - uses: actions/stale@v9 with: - stale-issue-message: "Эта задача давно не обновлялась. Она будет закрыта через 5 дней, если не появится новой активности." - stale-pr-message: "Этот PR замер. Мы закроем его через 5 дней, чтобы не копить очередь, но вы всегда можете переоткрыть его позже." + stale-issue-message: 'Эта задача давно не обновлялась. Она будет закрыта через 5 дней, если не появится новой активности.' + stale-pr-message: 'Этот PR замер. Мы закроем его через 5 дней, чтобы не копить очередь, но вы всегда можете переоткрыть его позже.' days-before-stale: 30 days-before-close: 5 diff --git a/.prettierignore b/.prettierignore new file mode 100644 index 0000000..c8d0ce7 --- /dev/null +++ b/.prettierignore @@ -0,0 +1,9 @@ +dist +node_modules +pnpm-lock.yaml + +migrations + +*.sql +Dockerfile* +.dockerignore \ No newline at end of file diff --git a/.prettierrc b/.prettierrc index c5c6203..a6643be 100644 --- a/.prettierrc +++ b/.prettierrc @@ -1,7 +1,7 @@ { - "singleQuote": true, - "trailingComma": "all", - "printWidth": 100, - "tabWidth": 4, - "semi": true + "singleQuote": true, + "trailingComma": "all", + "printWidth": 100, + "tabWidth": 4, + "semi": true } diff --git a/drizzle.config.ts b/drizzle.config.ts index 4bb294b..247cdcc 100644 --- a/drizzle.config.ts +++ b/drizzle.config.ts @@ -1,10 +1,10 @@ import { defineConfig } from 'drizzle-kit'; export default defineConfig({ - schema: './src/shared/entities/index.ts', - out: './migrations', - dialect: 'postgresql', - dbCredentials: { - url: process.env.DATABASE_URL!, - }, + schema: './src/shared/entities/index.ts', + out: './migrations', + dialect: 'postgresql', + dbCredentials: { + url: process.env.DATABASE_URL!, + }, }); diff --git a/infra/compose.dev.yaml b/infra/compose.dev.yaml index 7c54f3a..e7c4d67 100644 --- a/infra/compose.dev.yaml +++ b/infra/compose.dev.yaml @@ -1,54 +1,54 @@ -version: "3.9" +version: '3.9' name: task-tracker services: - api: - hostname: api - container_name: api - build: - context: ../ - dockerfile: Dockerfile.dev - restart: always - env_file: - - ../.env - ports: - - "3000:3000" - depends_on: - database: - condition: service_healthy - redis: - condition: service_started - networks: - - backend + api: + hostname: api + container_name: api + build: + context: ../ + dockerfile: Dockerfile.dev + restart: always + env_file: + - ../.env + ports: + - '3000:3000' + depends_on: + database: + condition: service_healthy + redis: + condition: service_started + networks: + - backend - database: - hostname: database - container_name: database - image: postgres:16-alpine - restart: always - env_file: - - ../.env - environment: - POSTGRES_USER: ${DB_USERNAME:-admin} - POSTGRES_PASSWORD: ${DB_PASSWORD:-admin} - POSTGRES_DB: ${DB_DATABASE:-tracker} - ports: - - "6000:5432" - volumes: - - postgres_data:/var/lib/postgresql/data - networks: - - backend - healthcheck: - test: ["CMD-SHELL", "pg_isready -U ${DB_USERNAME} -d ${DB_DATABASE}"] - interval: 5s - timeout: 5s - retries: 5 - profiles: ["infra"] + database: + hostname: database + container_name: database + image: postgres:16-alpine + restart: always + env_file: + - ../.env + environment: + POSTGRES_USER: ${DB_USERNAME:-admin} + POSTGRES_PASSWORD: ${DB_PASSWORD:-admin} + POSTGRES_DB: ${DB_DATABASE:-tracker} + ports: + - '6000:5432' + volumes: + - postgres_data:/var/lib/postgresql/data + networks: + - backend + healthcheck: + test: ['CMD-SHELL', 'pg_isready -U ${DB_USERNAME} -d ${DB_DATABASE}'] + interval: 5s + timeout: 5s + retries: 5 + profiles: ['infra'] volumes: - postgres_data: - redis_data: + postgres_data: + redis_data: networks: - backend: + backend: diff --git a/libs/bootstrap/src/configs/swagger.ts b/libs/bootstrap/src/configs/swagger.ts index 918911d..a13eb68 100644 --- a/libs/bootstrap/src/configs/swagger.ts +++ b/libs/bootstrap/src/configs/swagger.ts @@ -1,7 +1,7 @@ import type { SwaggerOptions } from '../interfaces/options.interface'; export const SWAGGER_DEFAULTS: SwaggerOptions = { - title: 'API', - description: 'API Documentation', - version: '1.0.0', + title: 'API', + description: 'API Documentation', + version: '1.0.0', }; diff --git a/libs/bootstrap/src/configs/throttler.ts b/libs/bootstrap/src/configs/throttler.ts index 135f264..08f8cbe 100644 --- a/libs/bootstrap/src/configs/throttler.ts +++ b/libs/bootstrap/src/configs/throttler.ts @@ -1,9 +1,9 @@ import type { ThrottlerModuleOptions } from '@nestjs/throttler'; export const DEFAULT_THROTTLER_OPTIONS: ThrottlerModuleOptions = [ - { - ttl: 60000, - limit: 100, - skipIf: (context) => context.getType() !== 'http', - }, + { + ttl: 60000, + limit: 100, + skipIf: (context) => context.getType() !== 'http', + }, ]; diff --git a/libs/bootstrap/src/interfaces/options.interface.ts b/libs/bootstrap/src/interfaces/options.interface.ts index 8b2f22c..fed3ded 100644 --- a/libs/bootstrap/src/interfaces/options.interface.ts +++ b/libs/bootstrap/src/interfaces/options.interface.ts @@ -4,32 +4,32 @@ import type { NestFastifyApplication } from '@nestjs/platform-fastify'; import type { ThrottlerModuleOptions } from '@nestjs/throttler'; export interface SwaggerMetadata { - title?: string; - description?: string; - version?: string; - path?: string; + title?: string; + description?: string; + version?: string; + path?: string; } export interface SwaggerInfrastructure { - server?: { - port?: string | number; - domain?: string; - stage?: string; - }; - services?: { name: string; port: number }[]; + server?: { + port?: string | number; + domain?: string; + stage?: string; + }; + services?: { name: string; port: number }[]; } export interface SwaggerOptions extends SwaggerMetadata, SwaggerInfrastructure {} export interface BootstrapOptions { - apiPrefix?: string; - appModule: Type; - defaultPort?: number; - portEnvKey?: keyof Config; - serviceName: string; - setupApp?: (app: NestFastifyApplication) => Promise | void; - swaggerOptions?: SwaggerMetadata; - throttlerOptions?: ThrottlerModuleOptions; - useCookieParser?: boolean; - useCors?: boolean; + apiPrefix?: string; + appModule: Type; + defaultPort?: number; + portEnvKey?: keyof Config; + serviceName: string; + setupApp?: (app: NestFastifyApplication) => Promise | void; + swaggerOptions?: SwaggerMetadata; + throttlerOptions?: ThrottlerModuleOptions; + useCookieParser?: boolean; + useCors?: boolean; } diff --git a/libs/bootstrap/src/setups/throttler.ts b/libs/bootstrap/src/setups/throttler.ts index 59ac61a..29f683b 100644 --- a/libs/bootstrap/src/setups/throttler.ts +++ b/libs/bootstrap/src/setups/throttler.ts @@ -4,16 +4,16 @@ import { APP_GUARD } from '@nestjs/core'; import { ThrottlerGuard, ThrottlerModule } from '@nestjs/throttler'; export function setupThrottler(module: Type, options: ThrottlerModuleOptions) { - @Module({ - imports: [module, ThrottlerModule.forRoot(options)], - providers: [ - { - provide: APP_GUARD, - useClass: ThrottlerGuard, - }, - ], - }) - class RootModule {} + @Module({ + imports: [module, ThrottlerModule.forRoot(options)], + providers: [ + { + provide: APP_GUARD, + useClass: ThrottlerGuard, + }, + ], + }) + class RootModule {} - return RootModule; + return RootModule; } diff --git a/libs/bootstrap/tsconfig.lib.json b/libs/bootstrap/tsconfig.lib.json index 208ac7d..909ede0 100644 --- a/libs/bootstrap/tsconfig.lib.json +++ b/libs/bootstrap/tsconfig.lib.json @@ -1,9 +1,9 @@ { - "extends": "../../tsconfig.json", - "compilerOptions": { - "declaration": true, - "outDir": "../../dist/libs/bootstrap" - }, - "include": ["src/**/*"], - "exclude": ["node_modules", "dist", "test", "**/*spec.ts"] + "extends": "../../tsconfig.json", + "compilerOptions": { + "declaration": true, + "outDir": "../../dist/libs/bootstrap" + }, + "include": ["src/**/*"], + "exclude": ["node_modules", "dist", "test", "**/*spec.ts"] } diff --git a/libs/config/tsconfig.lib.json b/libs/config/tsconfig.lib.json index ec3efa6..855908d 100644 --- a/libs/config/tsconfig.lib.json +++ b/libs/config/tsconfig.lib.json @@ -1,9 +1,9 @@ { - "extends": "../../tsconfig.json", - "compilerOptions": { - "declaration": true, - "outDir": "../../dist/libs/config" - }, - "include": ["src/**/*"], - "exclude": ["node_modules", "dist", "test", "**/*spec.ts"] + "extends": "../../tsconfig.json", + "compilerOptions": { + "declaration": true, + "outDir": "../../dist/libs/config" + }, + "include": ["src/**/*"], + "exclude": ["node_modules", "dist", "test", "**/*spec.ts"] } diff --git a/libs/database/tsconfig.lib.json b/libs/database/tsconfig.lib.json index 21c8d58..0add6d4 100644 --- a/libs/database/tsconfig.lib.json +++ b/libs/database/tsconfig.lib.json @@ -1,9 +1,9 @@ { - "extends": "../../tsconfig.json", - "compilerOptions": { - "declaration": true, - "outDir": "../../dist/libs/database" - }, - "include": ["src/**/*"], - "exclude": ["node_modules", "dist", "test", "**/*spec.ts"] + "extends": "../../tsconfig.json", + "compilerOptions": { + "declaration": true, + "outDir": "../../dist/libs/database" + }, + "include": ["src/**/*"], + "exclude": ["node_modules", "dist", "test", "**/*spec.ts"] } diff --git a/libs/health/tsconfig.lib.json b/libs/health/tsconfig.lib.json index 8e4d095..5c0ebaa 100644 --- a/libs/health/tsconfig.lib.json +++ b/libs/health/tsconfig.lib.json @@ -1,9 +1,9 @@ { - "extends": "../../tsconfig.json", - "compilerOptions": { - "declaration": true, - "outDir": "../../dist/libs/health" - }, - "include": ["src/**/*"], - "exclude": ["node_modules", "dist", "test", "**/*spec.ts"] + "extends": "../../tsconfig.json", + "compilerOptions": { + "declaration": true, + "outDir": "../../dist/libs/health" + }, + "include": ["src/**/*"], + "exclude": ["node_modules", "dist", "test", "**/*spec.ts"] } diff --git a/nest-cli.json b/nest-cli.json index 5881fec..03f8cdf 100644 --- a/nest-cli.json +++ b/nest-cli.json @@ -1,47 +1,47 @@ { - "$schema": "https://json.schemastore.org/nest-cli", - "collection": "@nestjs/schematics", - "sourceRoot": "src", - "compilerOptions": { - "deleteOutDir": true, - "webpack": true - }, - "projects": { - "bootstrap": { - "type": "library", - "root": "libs/bootstrap", - "entryFile": "index", - "sourceRoot": "libs/bootstrap/src", - "compilerOptions": { - "tsConfigPath": "libs/bootstrap/tsconfig.lib.json" - } + "$schema": "https://json.schemastore.org/nest-cli", + "collection": "@nestjs/schematics", + "sourceRoot": "src", + "compilerOptions": { + "deleteOutDir": true, + "webpack": true }, - "config": { - "type": "library", - "root": "libs/config", - "entryFile": "index", - "sourceRoot": "libs/config/src", - "compilerOptions": { - "tsConfigPath": "libs/config/tsconfig.lib.json" - } - }, - "database": { - "type": "library", - "root": "libs/database", - "entryFile": "index", - "sourceRoot": "libs/database/src", - "compilerOptions": { - "tsConfigPath": "libs/database/tsconfig.lib.json" - } - }, - "health": { - "type": "library", - "root": "libs/health", - "entryFile": "index", - "sourceRoot": "libs/health/src", - "compilerOptions": { - "tsConfigPath": "libs/health/tsconfig.lib.json" - } + "projects": { + "bootstrap": { + "type": "library", + "root": "libs/bootstrap", + "entryFile": "index", + "sourceRoot": "libs/bootstrap/src", + "compilerOptions": { + "tsConfigPath": "libs/bootstrap/tsconfig.lib.json" + } + }, + "config": { + "type": "library", + "root": "libs/config", + "entryFile": "index", + "sourceRoot": "libs/config/src", + "compilerOptions": { + "tsConfigPath": "libs/config/tsconfig.lib.json" + } + }, + "database": { + "type": "library", + "root": "libs/database", + "entryFile": "index", + "sourceRoot": "libs/database/src", + "compilerOptions": { + "tsConfigPath": "libs/database/tsconfig.lib.json" + } + }, + "health": { + "type": "library", + "root": "libs/health", + "entryFile": "index", + "sourceRoot": "libs/health/src", + "compilerOptions": { + "tsConfigPath": "libs/health/tsconfig.lib.json" + } + } } - } -} \ No newline at end of file +} diff --git a/package.json b/package.json index 3aee9e1..f202d2e 100644 --- a/package.json +++ b/package.json @@ -7,7 +7,7 @@ "license": "UNLICENSED", "scripts": { "build": "nest build", - "format": "prettier --write \"src/**/*.ts\" \"test/**/*.ts\" \"libs/**/*.ts\"", + "format": "prettier --write \".\"", "start": "nest start", "start:dev": "nest start --watch", "start:debug": "nest start --debug --watch", diff --git a/tsconfig.build.json b/tsconfig.build.json index 64f86c6..aed3485 100644 --- a/tsconfig.build.json +++ b/tsconfig.build.json @@ -1,4 +1,4 @@ { - "extends": "./tsconfig.json", - "exclude": ["node_modules", "test", "dist", "**/*spec.ts"] + "extends": "./tsconfig.json", + "exclude": ["node_modules", "test", "dist", "**/*spec.ts"] } diff --git a/tsconfig.json b/tsconfig.json index 759daf0..de35319 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -1,63 +1,41 @@ { - "compilerOptions": { - "module": "commonjs", - "declaration": false, - "removeComments": true, - "emitDecoratorMetadata": true, - "experimentalDecorators": true, - "allowSyntheticDefaultImports": true, - "target": "ES2021", - "sourceMap": true, - "outDir": "./dist", - "incremental": true, - "skipLibCheck": true, - "strictNullChecks": false, - "noImplicitAny": false, - "strictBindCallApply": false, - "forceConsistentCasingInFileNames": false, - "noFallthroughCasesInSwitch": false, - "types": [ - "node", - "vitest/globals" - ], - "paths": { - "@libs/bootstrap": [ - "./libs/bootstrap/src" - ], - "@libs/bootstrap/*": [ - "./libs/bootstrap/src/*" - ], - "@libs/config": [ - "./libs/config/src" - ], - "@libs/config/*": [ - "./libs/config/src/*" - ], - "@libs/database": [ - "./libs/database/src" - ], - "@libs/database/*": [ - "./libs/database/src/*" - ], - "@libs/health": [ - "libs/health/src" - ], - "@libs/health/*": [ - "libs/health/src/*" - ] + "compilerOptions": { + "module": "commonjs", + "declaration": false, + "removeComments": true, + "emitDecoratorMetadata": true, + "experimentalDecorators": true, + "allowSyntheticDefaultImports": true, + "target": "ES2021", + "sourceMap": true, + "outDir": "./dist", + "incremental": true, + "skipLibCheck": true, + "strictNullChecks": false, + "noImplicitAny": false, + "strictBindCallApply": false, + "forceConsistentCasingInFileNames": false, + "noFallthroughCasesInSwitch": false, + "types": ["node", "vitest/globals"], + "paths": { + "@libs/bootstrap": ["./libs/bootstrap/src"], + "@libs/bootstrap/*": ["./libs/bootstrap/src/*"], + "@libs/config": ["./libs/config/src"], + "@libs/config/*": ["./libs/config/src/*"], + "@libs/database": ["./libs/database/src"], + "@libs/database/*": ["./libs/database/src/*"], + "@libs/health": ["libs/health/src"], + "@libs/health/*": ["libs/health/src/*"] + }, + "baseUrl": "./" }, - "baseUrl": "./" - }, - "include": [ - "src/**/*", - "libs/**/*", - "test/**/*", - "drizzle.config.ts", - "vitest.config.ts", - "vitest.config.e2e.ts" - ], - "exclude": [ - "dist", - "node_modules" - ] -} \ No newline at end of file + "include": [ + "src/**/*", + "libs/**/*", + "test/**/*", + "drizzle.config.ts", + "vitest.config.ts", + "vitest.config.e2e.ts" + ], + "exclude": ["dist", "node_modules"] +}