diff --git a/.husky/pre-commit b/.husky/pre-commit new file mode 100644 index 0000000..ff6029d --- /dev/null +++ b/.husky/pre-commit @@ -0,0 +1,3 @@ +#!/bin/bash + +npx prettier --write ./src \ No newline at end of file diff --git a/.prettierrc b/.prettierrc index dcb7279..5e83886 100644 --- a/.prettierrc +++ b/.prettierrc @@ -1,4 +1,16 @@ { "singleQuote": true, - "trailingComma": "all" -} \ No newline at end of file + "trailingComma": "all", + "plugins": ["@trivago/prettier-plugin-sort-imports"], + "importOrder": [ + "^@nestjs/(.*)$", + "", + "^@src/(.*)$", + "^[./]" + ], + "importOrderSortSpecifiers": true, + "importOrderParserPlugins": [ + "typescript", + "[\"decorators-legacy\", { \"decoratorsBeforeExport\": true }]" + ] +} diff --git a/package.json b/package.json index 7fbce9c..c4c1c1d 100644 --- a/package.json +++ b/package.json @@ -29,7 +29,8 @@ "test:watch": "jest --watch", "test:cov": "jest --coverage", "test:debug": "node --inspect-brk -r tsconfig-paths/register -r ts-node/register node_modules/.bin/jest --runInBand", - "test:e2e": "jest --config ./test/jest-e2e.json" + "test:e2e": "jest --config ./test/jest-e2e.json", + "prepare": "husky" }, "dependencies": { "@aws-sdk/client-lambda": "^3.606.0", @@ -67,6 +68,7 @@ "@sentry/webpack-plugin": "^2.20.1", "@swc/cli": "^0.3.14", "@swc/core": "^1.6.5", + "@trivago/prettier-plugin-sort-imports": "^4.3.0", "@types/express": "^4.17.17", "@types/jest": "^29.5.2", "@types/lodash": "^4.17.6", @@ -80,6 +82,7 @@ "eslint": "^8.42.0", "eslint-config-prettier": "^9.0.0", "eslint-plugin-prettier": "^5.0.0", + "husky": "^9.1.6", "jest": "^29.5.0", "prettier": "^3.0.0", "rimraf": "^5.0.7", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 2d10239..825faab 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -108,6 +108,9 @@ importers: '@swc/core': specifier: ^1.6.5 version: 1.6.5 + '@trivago/prettier-plugin-sort-imports': + specifier: ^4.3.0 + version: 4.3.0(prettier@3.3.2) '@types/express': specifier: ^4.17.17 version: 4.17.21 @@ -147,6 +150,9 @@ importers: eslint-plugin-prettier: specifier: ^5.0.0 version: 5.1.3(@types/eslint@8.56.10)(eslint-config-prettier@9.1.0(eslint@8.57.0))(eslint@8.57.0)(prettier@3.3.2) + husky: + specifier: ^9.1.6 + version: 9.1.6 jest: specifier: ^29.5.0 version: 29.7.0(@types/node@20.14.9)(ts-node@10.9.2(@swc/core@1.6.5)(@types/node@20.14.9)(typescript@5.5.2)) @@ -454,6 +460,10 @@ packages: resolution: {integrity: sha512-nykK+LEK86ahTkX/3TgauT0ikKoNCfKHEaZYTUVupJdTLzGNvrblu4u6fa7DhZONAltdf8e662t/abY8idrd/g==} engines: {node: '>=6.9.0'} + '@babel/generator@7.17.7': + resolution: {integrity: sha512-oLcVCTeIFadUoArDTwpluncplrYBmTCCZZgXCbgNGvOBBiSDDK3eWO4b/+eOTli5tKv1lg+a5/NAXg+nTcei1w==} + engines: {node: '>=6.9.0'} + '@babel/generator@7.24.7': resolution: {integrity: sha512-oipXieGC3i45Y1A41t4tAqpnEZWgB/lC6Ehh6+rOviR5XWpTtMmLN+fGjz9vOiNRt0p6RtO6DtD0pdU3vpqdSA==} engines: {node: '>=6.9.0'} @@ -598,10 +608,18 @@ packages: resolution: {integrity: sha512-jYqfPrU9JTF0PmPy1tLYHW4Mp4KlgxJD9l2nP9fD6yT/ICi554DmrWBAEYpIelzjHf1msDP3PxJIRt/nFNfBig==} engines: {node: '>=6.9.0'} + '@babel/traverse@7.23.2': + resolution: {integrity: sha512-azpe59SQ48qG6nu2CzcMLbxUudtN+dOM9kDbUqGq3HXUJRlo7i8fvPoxQUzYgLZ4cMVmuZgm8vvBpNeRhd6XSw==} + engines: {node: '>=6.9.0'} + '@babel/traverse@7.24.7': resolution: {integrity: sha512-yb65Ed5S/QAcewNPh0nZczy9JdYXkkAbIsEo+P7BE7yO3txAY30Y/oPa3QkQ5It3xVG2kpKMg9MsdxZaO31uKA==} engines: {node: '>=6.9.0'} + '@babel/types@7.17.0': + resolution: {integrity: sha512-TmKSNO4D5rzhL5bjWFcVHHLETzfQ/AmbKpKPOSjlP0WoHZ6L911fgoOKY4Alp/emzG4cHJdyN49zpgkbXFEHHw==} + engines: {node: '>=6.9.0'} + '@babel/types@7.24.7': resolution: {integrity: sha512-XEFXSlxiG5td2EJRe8vOmRbaXVgfcBlszKujvVmWIK/UpywWljQCfzAv3RQCGujWQ1RD4YYWEAqDXfuJiy8f5Q==} engines: {node: '>=6.9.0'} @@ -1706,6 +1724,15 @@ packages: '@tootallnate/quickjs-emscripten@0.23.0': resolution: {integrity: sha512-C5Mc6rdnsaJDjO3UpGW/CQTHtCKaYlScZTly4JIu97Jxo/odCiH0ITnDXSJPTOrEKk/ycSZ0AOgTmkDtkOsvIA==} + '@trivago/prettier-plugin-sort-imports@4.3.0': + resolution: {integrity: sha512-r3n0onD3BTOVUNPhR4lhVK4/pABGpbA7bW3eumZnYdKaHkf1qEC+Mag6DPbGNuuh0eG8AaYj+YqmVHSiGslaTQ==} + peerDependencies: + '@vue/compiler-sfc': 3.x + prettier: 2.x - 3.x + peerDependenciesMeta: + '@vue/compiler-sfc': + optional: true + '@tsconfig/node10@1.0.11': resolution: {integrity: sha512-DcRjDCujK/kCk/cUe8Xz8ZSpm8mS3mNNpta+jGCA6USEDfktlNvm1+IuZ9eTcDbNk41BHwpHHeW+N1lKCz4zOw==} @@ -3226,6 +3253,11 @@ packages: humanize-ms@1.2.1: resolution: {integrity: sha512-Fl70vYtsAFb/C06PTS9dZBo7ihau+Tu/DNCk/OyHhea07S+aeMWpFFkUaXRa8fI+ScZbEI8dfSxwY7gxZ9SAVQ==} + husky@9.1.6: + resolution: {integrity: sha512-sqbjZKK7kf44hfdE94EoX8MZNk0n7HeW37O4YrVGCF4wzgQjp+akPAkfUK5LZ6KuR/6sqeAVuXHji+RzQgOn5A==} + engines: {node: '>=18'} + hasBin: true + iconv-lite@0.4.24: resolution: {integrity: sha512-v3MXnZAcvnywkTUEZomIActle7RXXeedOR31wwl7VlyoXO4Qi9arvSenNQWne1TcRwhCL1HwLI21bEqdpj8/rA==} engines: {node: '>=0.10.0'} @@ -3446,6 +3478,9 @@ packages: resolution: {integrity: sha512-gZmQKe1QrfkkMjCn8Qv9cpyJFyogTYqkP5WCobX5RNaHsJzIV/6NvAnlnouOcwKr29QrxLGDGcqYuJ+ae98s1A==} hasBin: true + javascript-natural-sort@0.7.1: + resolution: {integrity: sha512-nO6jcEfZWQXDhOiBtG2KvKyEptz7RVbpGP4vTD2hLBdmNQSsCiicO2Ioinv6UI4y9ukqnBpy+XZ9H6uLNgJTlw==} + jest-changed-files@29.7.0: resolution: {integrity: sha512-fEArFiwf1BpQ+4bXSprcDc3/x4HSzL4al2tozwVpDFpsxALjLYdyiIK4e5Vz66GQJIbXJ82+35PtysofptNX2w==} engines: {node: ^14.15.0 || ^16.10.0 || >=18.0.0} @@ -4603,6 +4638,10 @@ packages: source-map-support@0.5.21: resolution: {integrity: sha512-uBHU3L3czsIyYXKX88fdrGovxdSCoTGDRZ6SYXtSRxLZUzHg5P/66Ht6uoUlHu9EZod+inXhKo3qQgwXUT/y1w==} + source-map@0.5.7: + resolution: {integrity: sha512-LbrmJOMUSdEVxIKvdcJzQC+nQhe8FUZQTXQy6+I75skNgn3OoQ0DZA8YnFa7gp8tqtL3KPf1kmo0R5DoApeSGQ==} + engines: {node: '>=0.10.0'} + source-map@0.6.1: resolution: {integrity: sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==} engines: {node: '>=0.10.0'} @@ -6397,6 +6436,12 @@ snapshots: transitivePeerDependencies: - supports-color + '@babel/generator@7.17.7': + dependencies: + '@babel/types': 7.24.7 + jsesc: 2.5.2 + source-map: 0.5.7 + '@babel/generator@7.24.7': dependencies: '@babel/types': 7.24.7 @@ -6554,6 +6599,21 @@ snapshots: '@babel/parser': 7.24.7 '@babel/types': 7.24.7 + '@babel/traverse@7.23.2': + dependencies: + '@babel/code-frame': 7.24.7 + '@babel/generator': 7.24.7 + '@babel/helper-environment-visitor': 7.24.7 + '@babel/helper-function-name': 7.24.7 + '@babel/helper-hoist-variables': 7.24.7 + '@babel/helper-split-export-declaration': 7.24.7 + '@babel/parser': 7.24.7 + '@babel/types': 7.24.7 + debug: 4.3.5 + globals: 11.12.0 + transitivePeerDependencies: + - supports-color + '@babel/traverse@7.24.7': dependencies: '@babel/code-frame': 7.24.7 @@ -6569,6 +6629,11 @@ snapshots: transitivePeerDependencies: - supports-color + '@babel/types@7.17.0': + dependencies: + '@babel/helper-validator-identifier': 7.24.7 + to-fast-properties: 2.0.0 + '@babel/types@7.24.7': dependencies: '@babel/helper-string-parser': 7.24.7 @@ -8151,6 +8216,18 @@ snapshots: '@tootallnate/quickjs-emscripten@0.23.0': {} + '@trivago/prettier-plugin-sort-imports@4.3.0(prettier@3.3.2)': + dependencies: + '@babel/generator': 7.17.7 + '@babel/parser': 7.24.7 + '@babel/traverse': 7.23.2 + '@babel/types': 7.17.0 + javascript-natural-sort: 0.7.1 + lodash: 4.17.21 + prettier: 3.3.2 + transitivePeerDependencies: + - supports-color + '@tsconfig/node10@1.0.11': {} '@tsconfig/node12@1.0.11': {} @@ -9917,6 +9994,8 @@ snapshots: dependencies: ms: 2.1.3 + husky@9.1.6: {} + iconv-lite@0.4.24: dependencies: safer-buffer: 2.1.2 @@ -10152,6 +10231,8 @@ snapshots: java-invoke-local@0.0.6: {} + javascript-natural-sort@0.7.1: {} + jest-changed-files@29.7.0: dependencies: execa: 5.1.1 @@ -11467,6 +11548,8 @@ snapshots: buffer-from: 1.1.2 source-map: 0.6.1 + source-map@0.5.7: {} + source-map@0.6.1: {} source-map@0.7.4: {} @@ -12035,4 +12118,4 @@ snapshots: yn@3.1.1: {} - yocto-queue@0.1.0: {} \ No newline at end of file + yocto-queue@0.1.0: {} diff --git a/src/app.controller.ts b/src/app.controller.ts index 51f01cf..249e816 100644 --- a/src/app.controller.ts +++ b/src/app.controller.ts @@ -1,6 +1,5 @@ // Nest Packagess import { Controller, Get } from '@nestjs/common'; - // Custom Packages import { AppService } from './app.service'; diff --git a/src/app.module.ts b/src/app.module.ts index 075b677..93f0a01 100644 --- a/src/app.module.ts +++ b/src/app.module.ts @@ -1,6 +1,5 @@ // Nest Packages import { MiddlewareConsumer, Module, NestModule } from '@nestjs/common'; - // Custom Packages import { ConfigModule } from '@nestjs/config'; import { DatabaseModule } from '@src/infrastructure'; @@ -13,12 +12,12 @@ import { DiscordModule } from './infrastructure/discord/discord.module'; import { AuthModule } from './modules/auth/auth.module'; import { ClassificationModule } from './modules/classification/classification.module'; import { FoldersModule } from './modules/folders/folders.module'; +import { LaunchingEventsModule } from './modules/launching-events/launching-events.module'; import { LinksModule } from './modules/links/links.module'; import { MetricsModule } from './modules/metrics/metrics.module'; import { OnboardModule } from './modules/onboard/onboard.module'; import { PostsModule } from './modules/posts/posts.module'; import { UsersModule } from './modules/users/users.module'; -import { LaunchingEventsModule } from './modules/launching-events/launching-events.module'; @Module({ imports: [ diff --git a/src/bootstrap.ts b/src/bootstrap.ts index cb2ab67..6d0fefd 100644 --- a/src/bootstrap.ts +++ b/src/bootstrap.ts @@ -1,9 +1,9 @@ import { NestFactory } from '@nestjs/core'; import { ExpressAdapter } from '@nestjs/platform-express'; import express from 'express'; +import { nestAppConfig, nestResponseConfig } from './app.config'; import { AppModule } from './app.module'; import { nestSwaggerConfig } from './app.swagger'; -import { nestAppConfig, nestResponseConfig } from './app.config'; export async function bootstrap() { const expressInstance: express.Express = express(); diff --git a/src/common/decorators/getUser.decorator.ts b/src/common/decorators/getUser.decorator.ts index 0fff3e0..aa7f965 100644 --- a/src/common/decorators/getUser.decorator.ts +++ b/src/common/decorators/getUser.decorator.ts @@ -3,8 +3,8 @@ import { UnauthorizedException, createParamDecorator, } from '@nestjs/common'; -import { ReqUserPayload } from '../types/type'; import { Request } from 'express'; +import { ReqUserPayload } from '../types/type'; /** * @GetUser diff --git a/src/common/filter/base.filter.ts b/src/common/filter/base.filter.ts index 89e3321..21cb55b 100644 --- a/src/common/filter/base.filter.ts +++ b/src/common/filter/base.filter.ts @@ -5,8 +5,8 @@ import { HttpException, } from '@nestjs/common'; import { captureException } from '@sentry/node'; -import { DiscordErrorWebhookProvider } from '@src/infrastructure/discord/discord-error-webhook.provider'; import { Response } from 'express'; +import { DiscordErrorWebhookProvider } from '@src/infrastructure/discord/discord-error-webhook.provider'; import { RootException, createException } from '../error'; import { ExceptionPayload, ICommonResponse } from '../types/type'; diff --git a/src/common/types/type.d.ts b/src/common/types/type.d.ts index 006d2cb..d57b8e7 100644 --- a/src/common/types/type.d.ts +++ b/src/common/types/type.d.ts @@ -1,4 +1,5 @@ import { Types } from 'mongoose'; + // Exception Payload export type ExceptionPayload = { code?: string; diff --git a/src/handler.ts b/src/handler.ts index 02768a6..306ff3b 100644 --- a/src/handler.ts +++ b/src/handler.ts @@ -2,6 +2,7 @@ import { Context, Handler } from 'aws-lambda'; import { createServer, proxy } from 'aws-serverless-express'; import { Server } from 'http'; import { bootstrap, runServer } from './bootstrap'; + let cachedServer: Server; export const handler: Handler = async (event: any, context: Context) => { if (!cachedServer) { diff --git a/src/infrastructure/aws-lambda/aws-lambda.service.ts b/src/infrastructure/aws-lambda/aws-lambda.service.ts index b8062e2..52ca8fa 100644 --- a/src/infrastructure/aws-lambda/aws-lambda.service.ts +++ b/src/infrastructure/aws-lambda/aws-lambda.service.ts @@ -1,6 +1,6 @@ -import { InvokeCommand, LambdaClient } from '@aws-sdk/client-lambda'; import { Injectable } from '@nestjs/common'; import { ConfigService } from '@nestjs/config'; +import { InvokeCommand, LambdaClient } from '@aws-sdk/client-lambda'; import { AiClassificationPayload } from './type'; @Injectable() diff --git a/src/infrastructure/database/schema/AIClassification.schema.ts b/src/infrastructure/database/schema/AIClassification.schema.ts index d5af70e..6b30c3f 100644 --- a/src/infrastructure/database/schema/AIClassification.schema.ts +++ b/src/infrastructure/database/schema/AIClassification.schema.ts @@ -1,6 +1,5 @@ import { Prop, Schema, SchemaFactory } from '@nestjs/mongoose'; import { HydratedDocument, Schema as MongooseSchema } from 'mongoose'; - import { BaseDocument } from './base.schema'; @Schema({ diff --git a/src/infrastructure/database/schema/post.schema.ts b/src/infrastructure/database/schema/post.schema.ts index c06667b..eea6237 100644 --- a/src/infrastructure/database/schema/post.schema.ts +++ b/src/infrastructure/database/schema/post.schema.ts @@ -1,8 +1,8 @@ import { Prop, Schema, SchemaFactory } from '@nestjs/mongoose'; import { HydratedDocument, Schema as MongooseSchema } from 'mongoose'; -import { BaseDocument } from './base.schema'; -import { AIClassification } from './AIClassification.schema'; import { PostAiStatus } from '@src/modules/posts/posts.constant'; +import { AIClassification } from './AIClassification.schema'; +import { BaseDocument } from './base.schema'; @Schema({ collection: 'posts', timestamps: true, versionKey: false }) export class Post extends BaseDocument { diff --git a/src/modules/auth/auth.module.ts b/src/modules/auth/auth.module.ts index 0980edc..e5efdcc 100644 --- a/src/modules/auth/auth.module.ts +++ b/src/modules/auth/auth.module.ts @@ -1,6 +1,6 @@ import { Module } from '@nestjs/common'; -import { AuthService } from './auth.service'; import { JwtModule } from '@nestjs/jwt'; +import { AuthService } from './auth.service'; @Module({ imports: [ diff --git a/src/modules/classification/classification.module.ts b/src/modules/classification/classification.module.ts index 9c91049..812e1af 100644 --- a/src/modules/classification/classification.module.ts +++ b/src/modules/classification/classification.module.ts @@ -8,11 +8,10 @@ import { Post, PostSchema, } from '@src/infrastructure/database/schema'; -import { ClassificationService } from './classification.service'; - import { PostsRepository } from '../posts/posts.repository'; import { ClassificationController } from './classification.controller'; import { ClassficiationRepository } from './classification.repository'; +import { ClassificationService } from './classification.service'; @Module({ imports: [ diff --git a/src/modules/classification/classification.repository.ts b/src/modules/classification/classification.repository.ts index 3454407..1e22b95 100644 --- a/src/modules/classification/classification.repository.ts +++ b/src/modules/classification/classification.repository.ts @@ -1,8 +1,8 @@ import { Injectable } from '@nestjs/common'; import { InjectModel } from '@nestjs/mongoose'; +import { Model, Types } from 'mongoose'; import { AIClassification, Folder } from '@src/infrastructure'; import { FolderType } from '@src/infrastructure/database/types/folder-type.enum'; -import { Model, Types } from 'mongoose'; import { ClassificationFolderWithCount } from './dto/classification.dto'; @Injectable() diff --git a/src/modules/classification/classification.service.ts b/src/modules/classification/classification.service.ts index a6c9b16..c8db176 100644 --- a/src/modules/classification/classification.service.ts +++ b/src/modules/classification/classification.service.ts @@ -1,13 +1,11 @@ import { Injectable } from '@nestjs/common'; - import { BadRequestException } from '@nestjs/common'; -import { PaginationQuery } from '@src/common'; import { Types } from 'mongoose'; +import { PaginationQuery } from '@src/common'; +import { sum } from '@src/common'; import { PostsRepository } from '../posts/posts.repository'; import { ClassficiationRepository } from './classification.repository'; import { ClassificationFolderWithCount } from './dto/classification.dto'; - -import { sum } from '@src/common'; import { C001 } from './error'; @Injectable() diff --git a/src/modules/classification/dto/getAIFolderNameLIst.dto.ts b/src/modules/classification/dto/getAIFolderNameLIst.dto.ts index bc5012b..d63c9bf 100644 --- a/src/modules/classification/dto/getAIFolderNameLIst.dto.ts +++ b/src/modules/classification/dto/getAIFolderNameLIst.dto.ts @@ -1,6 +1,6 @@ import { ApiProperty } from '@nestjs/swagger'; -import { FolderDocument } from '@src/infrastructure'; import { IsNotEmpty, IsString } from 'class-validator'; +import { FolderDocument } from '@src/infrastructure'; export class AIFolderNameServiceDto { id: string; diff --git a/src/modules/classification/response/ai-folder-list.dto.ts b/src/modules/classification/response/ai-folder-list.dto.ts index 96b07b7..26ed141 100644 --- a/src/modules/classification/response/ai-folder-list.dto.ts +++ b/src/modules/classification/response/ai-folder-list.dto.ts @@ -1,5 +1,4 @@ import { ApiProperty } from '@nestjs/swagger'; -import { AIFolderNameServiceDto } from '../dto/getAIFolderNameLIst.dto'; import { ClassificationFolderWithCount } from '../dto/classification.dto'; export class AIFolderNameListResponse { diff --git a/src/modules/classification/response/ai-post-list.dto.ts b/src/modules/classification/response/ai-post-list.dto.ts index 6ef7ec1..5e17896 100644 --- a/src/modules/classification/response/ai-post-list.dto.ts +++ b/src/modules/classification/response/ai-post-list.dto.ts @@ -1,6 +1,6 @@ import { ApiProperty } from '@nestjs/swagger'; -import { ClassificationPostList } from '../dto/classification.dto'; import { PaginationMetadata } from '@src/common'; +import { ClassificationPostList } from '../dto/classification.dto'; export class AIPostListResponse { @ApiProperty({ diff --git a/src/modules/folders/folders.repository.ts b/src/modules/folders/folders.repository.ts index 4348340..fbe3b3d 100644 --- a/src/modules/folders/folders.repository.ts +++ b/src/modules/folders/folders.repository.ts @@ -1,8 +1,8 @@ import { Injectable, NotFoundException } from '@nestjs/common'; import { InjectModel } from '@nestjs/mongoose'; +import { FilterQuery, Model } from 'mongoose'; import { Folder, FolderDocument } from '@src/infrastructure'; import { FolderType } from '@src/infrastructure/database/types/folder-type.enum'; -import { FilterQuery, Model } from 'mongoose'; import { F002 } from './error'; @Injectable() diff --git a/src/modules/folders/folders.service.ts b/src/modules/folders/folders.service.ts index cd87e30..0e051f6 100644 --- a/src/modules/folders/folders.service.ts +++ b/src/modules/folders/folders.service.ts @@ -1,7 +1,7 @@ import { BadRequestException, Injectable } from '@nestjs/common'; +import { Types } from 'mongoose'; import { sum } from '@src/common'; import { FolderType } from '@src/infrastructure/database/types/folder-type.enum'; -import { Types } from 'mongoose'; import { PostsRepository } from '../posts/posts.repository'; import { FolderListServiceDto } from './dto/folder-list-service.dto'; import { CreateFolderDto, UpdateFolderDto } from './dto/mutate-folder.dto'; diff --git a/src/modules/folders/responses/post.response.ts b/src/modules/folders/responses/post.response.ts index 8547a0a..0c7a0cf 100644 --- a/src/modules/folders/responses/post.response.ts +++ b/src/modules/folders/responses/post.response.ts @@ -1,8 +1,8 @@ import { ApiProperty } from '@nestjs/swagger'; +import { Types } from 'mongoose'; import { Keyword, Post } from '@src/infrastructure'; import { PostAiStatus } from '@src/modules/posts/posts.constant'; import { KeywordItem } from '@src/modules/posts/response/keyword-list.response'; -import { Types } from 'mongoose'; /** * @todo diff --git a/src/modules/keywords/keyword.repository.ts b/src/modules/keywords/keyword.repository.ts index ff14a5a..dc70ab4 100644 --- a/src/modules/keywords/keyword.repository.ts +++ b/src/modules/keywords/keyword.repository.ts @@ -1,7 +1,7 @@ import { Injectable } from '@nestjs/common'; import { InjectModel } from '@nestjs/mongoose'; -import { Keyword } from '@src/infrastructure'; import { Model } from 'mongoose'; +import { Keyword } from '@src/infrastructure'; @Injectable() export class KeywordsRepository { diff --git a/src/modules/links/links.controller.ts b/src/modules/links/links.controller.ts index 170d1bd..11d3a8c 100644 --- a/src/modules/links/links.controller.ts +++ b/src/modules/links/links.controller.ts @@ -1,7 +1,7 @@ import { Controller, Get, Query } from '@nestjs/common'; +import { LinksControllerDocs, ValidateLinkDocs } from './docs'; import { LinksService } from './links.service'; import { ValidateLinkResponse } from './responses'; -import { LinksControllerDocs, ValidateLinkDocs } from './docs'; @LinksControllerDocs @Controller('links') diff --git a/src/modules/links/links.module.ts b/src/modules/links/links.module.ts index 4249055..b2569d6 100644 --- a/src/modules/links/links.module.ts +++ b/src/modules/links/links.module.ts @@ -1,6 +1,6 @@ import { Module } from '@nestjs/common'; -import { LinksService } from './links.service'; import { LinksController } from './links.controller'; +import { LinksService } from './links.service'; @Module({ controllers: [LinksController], diff --git a/src/modules/metrics/metrics.repository.ts b/src/modules/metrics/metrics.repository.ts index c2ce1f0..ee41c8b 100644 --- a/src/modules/metrics/metrics.repository.ts +++ b/src/modules/metrics/metrics.repository.ts @@ -1,7 +1,7 @@ import { Injectable } from '@nestjs/common'; import { InjectModel } from '@nestjs/mongoose'; -import { Metrics } from '@src/infrastructure'; import { Model } from 'mongoose'; +import { Metrics } from '@src/infrastructure'; @Injectable() export class MetricsRepository { diff --git a/src/modules/onboard/onboard.controller.ts b/src/modules/onboard/onboard.controller.ts index ef6506f..2aec602 100644 --- a/src/modules/onboard/onboard.controller.ts +++ b/src/modules/onboard/onboard.controller.ts @@ -1,7 +1,7 @@ import { Controller, Get, Query } from '@nestjs/common'; -import { OnboardService } from './onboard.service'; -import { OnBoardQuery } from './dto'; import { ListOnBoardKeywordsDocs, OnBoardControllerDocs } from './docs'; +import { OnBoardQuery } from './dto'; +import { OnboardService } from './onboard.service'; @Controller('onboard') @OnBoardControllerDocs diff --git a/src/modules/onboard/onboard.module.ts b/src/modules/onboard/onboard.module.ts index 5370a77..88edfef 100644 --- a/src/modules/onboard/onboard.module.ts +++ b/src/modules/onboard/onboard.module.ts @@ -1,6 +1,6 @@ import { Module } from '@nestjs/common'; -import { OnboardService } from './onboard.service'; import { OnboardController } from './onboard.controller'; +import { OnboardService } from './onboard.service'; @Module({ providers: [OnboardService], diff --git a/src/modules/onboard/onboard.service.ts b/src/modules/onboard/onboard.service.ts index 72fc57d..dedf58c 100644 --- a/src/modules/onboard/onboard.service.ts +++ b/src/modules/onboard/onboard.service.ts @@ -1,7 +1,7 @@ import { Injectable } from '@nestjs/common'; -import { onBoardCategoryList } from './onboard.const'; -import { OnBoardQuery } from './dto'; import * as _ from 'lodash'; +import { OnBoardQuery } from './dto'; +import { onBoardCategoryList } from './onboard.const'; @Injectable() export class OnboardService { diff --git a/src/modules/posts/dto/create-post.dto.ts b/src/modules/posts/dto/create-post.dto.ts index dcd8251..38176a7 100644 --- a/src/modules/posts/dto/create-post.dto.ts +++ b/src/modules/posts/dto/create-post.dto.ts @@ -1,5 +1,5 @@ -import { IsMongoId, IsNotEmpty, IsUrl } from 'class-validator'; import { ApiProperty } from '@nestjs/swagger'; +import { IsMongoId, IsNotEmpty, IsUrl } from 'class-validator'; export class CreatePostDto { @IsMongoId() diff --git a/src/modules/posts/dto/find-in-folder.dto.ts b/src/modules/posts/dto/find-in-folder.dto.ts index 0426ea6..1e472cc 100644 --- a/src/modules/posts/dto/find-in-folder.dto.ts +++ b/src/modules/posts/dto/find-in-folder.dto.ts @@ -1,7 +1,7 @@ import { ApiProperty } from '@nestjs/swagger'; -import { PaginationQuery } from '@src/common'; -import { IsBoolean, IsOptional } from 'class-validator'; import { Transform } from 'class-transformer'; +import { IsBoolean, IsOptional } from 'class-validator'; +import { PaginationQuery } from '@src/common'; export class GetPostQueryDto extends PaginationQuery { @ApiProperty({ diff --git a/src/modules/posts/dto/list-post.dto.ts b/src/modules/posts/dto/list-post.dto.ts index 5b6ec9c..4efa6e9 100644 --- a/src/modules/posts/dto/list-post.dto.ts +++ b/src/modules/posts/dto/list-post.dto.ts @@ -1,7 +1,7 @@ import { ApiProperty } from '@nestjs/swagger'; -import { PaginationQuery } from '@src/common'; import { Transform } from 'class-transformer'; import { IsBoolean, IsOptional } from 'class-validator'; +import { PaginationQuery } from '@src/common'; export class ListPostQueryDto extends PaginationQuery { @ApiProperty({ diff --git a/src/modules/posts/postKeywords.repository.ts b/src/modules/posts/postKeywords.repository.ts index 73c252f..4243a6b 100644 --- a/src/modules/posts/postKeywords.repository.ts +++ b/src/modules/posts/postKeywords.repository.ts @@ -1,7 +1,7 @@ import { Injectable } from '@nestjs/common'; import { InjectModel } from '@nestjs/mongoose'; -import { PostKeyword } from '@src/infrastructure/database/schema/postKeyword.schema'; import { Model, Types } from 'mongoose'; +import { PostKeyword } from '@src/infrastructure/database/schema/postKeyword.schema'; @Injectable() export class PostKeywordsRepository { diff --git a/src/modules/posts/posts.repository.ts b/src/modules/posts/posts.repository.ts index 585e12c..c7a7aa0 100644 --- a/src/modules/posts/posts.repository.ts +++ b/src/modules/posts/posts.repository.ts @@ -1,9 +1,9 @@ import { Injectable, NotFoundException } from '@nestjs/common'; import { InjectModel } from '@nestjs/mongoose'; +import { FilterQuery, Model, Types } from 'mongoose'; import { OrderType } from '@src/common'; import { AIClassification, Post, PostDocument } from '@src/infrastructure'; import { PostAiStatus } from '@src/modules/posts/posts.constant'; -import { FilterQuery, Model, Types } from 'mongoose'; import { ClassificationPostList } from '../classification/dto/classification.dto'; import { P001 } from './error'; import { PostUpdateableFields } from './type/type'; diff --git a/src/modules/posts/posts.service.ts b/src/modules/posts/posts.service.ts index ebfa9eb..39870e5 100644 --- a/src/modules/posts/posts.service.ts +++ b/src/modules/posts/posts.service.ts @@ -1,5 +1,6 @@ import { Injectable } from '@nestjs/common'; import { ConfigService } from '@nestjs/config'; +import { FlattenMaps, Types } from 'mongoose'; import { parseLinkTitleAndContent } from '@src/common'; import { IS_LOCAL } from '@src/common/constant'; import { Keyword, Post } from '@src/infrastructure'; @@ -9,7 +10,6 @@ import { FolderType } from '@src/infrastructure/database/types/folder-type.enum' import { CreatePostDto } from '@src/modules/posts/dto/create-post.dto'; import { PostAiStatus } from '@src/modules/posts/posts.constant'; import { PostsRepository } from '@src/modules/posts/posts.repository'; -import { FlattenMaps, Types } from 'mongoose'; import { AiClassificationService } from '../ai-classification/ai-classification.service'; import { FolderRepository } from '../folders/folders.repository'; import { diff --git a/src/modules/posts/response/keyword-list.response.ts b/src/modules/posts/response/keyword-list.response.ts index 004fb1e..484fa3f 100644 --- a/src/modules/posts/response/keyword-list.response.ts +++ b/src/modules/posts/response/keyword-list.response.ts @@ -1,6 +1,6 @@ import { ApiProperty } from '@nestjs/swagger'; -import { Keyword } from '@src/infrastructure'; import { Types } from 'mongoose'; +import { Keyword } from '@src/infrastructure'; export class KeywordItem { @ApiProperty({ description: '키워드 id' }) diff --git a/src/modules/posts/response/listPost.response.ts b/src/modules/posts/response/listPost.response.ts index 3509968..c983dd7 100644 --- a/src/modules/posts/response/listPost.response.ts +++ b/src/modules/posts/response/listPost.response.ts @@ -1,8 +1,8 @@ import { ApiProperty } from '@nestjs/swagger'; +import { Types } from 'mongoose'; import { PaginationMetadata } from '@src/common'; import { Keyword, Post } from '@src/infrastructure'; import { PostAiStatus } from '@src/modules/posts/posts.constant'; -import { Types } from 'mongoose'; import { KeywordItem } from './keyword-list.response'; export type PostItemDto = Post & { diff --git a/src/modules/posts/response/retrievePost.response.ts b/src/modules/posts/response/retrievePost.response.ts index 8a7836e..46be54e 100644 --- a/src/modules/posts/response/retrievePost.response.ts +++ b/src/modules/posts/response/retrievePost.response.ts @@ -1,6 +1,6 @@ import { ApiProperty } from '@nestjs/swagger'; -import { Post } from '@src/infrastructure'; import { Types } from 'mongoose'; +import { Post } from '@src/infrastructure'; import { PostAiStatus } from '../posts.constant'; import { KeywordItem } from './keyword-list.response'; diff --git a/src/modules/users/guards/jwt.guard.ts b/src/modules/users/guards/jwt.guard.ts index 147d90f..886b6da 100644 --- a/src/modules/users/guards/jwt.guard.ts +++ b/src/modules/users/guards/jwt.guard.ts @@ -1,8 +1,8 @@ -import { AuthGuard } from '@nestjs/passport'; import { ExecutionContext, Injectable } from '@nestjs/common'; import { Reflector } from '@nestjs/core'; -import { JWT_STRATEGY_TOKEN } from '@src/modules/users/guards/strategy/strategy.token'; +import { AuthGuard } from '@nestjs/passport'; import { PublicRouteToken } from '@src/common'; +import { JWT_STRATEGY_TOKEN } from '@src/modules/users/guards/strategy/strategy.token'; @Injectable() export class JwtGuard extends AuthGuard(JWT_STRATEGY_TOKEN) { diff --git a/src/modules/users/guards/strategy/jwt.strategy.ts b/src/modules/users/guards/strategy/jwt.strategy.ts index f75b3e6..7ad3f38 100644 --- a/src/modules/users/guards/strategy/jwt.strategy.ts +++ b/src/modules/users/guards/strategy/jwt.strategy.ts @@ -1,12 +1,12 @@ -import { PassportStrategy } from '@nestjs/passport'; -import { ExtractJwt, Strategy } from 'passport-jwt'; -import { JWT_STRATEGY_TOKEN } from './strategy.token'; import { Injectable, UnauthorizedException } from '@nestjs/common'; +import { ConfigService } from '@nestjs/config'; import { InjectModel } from '@nestjs/mongoose'; +import { PassportStrategy } from '@nestjs/passport'; import { Model } from 'mongoose'; -import { ConfigService } from '@nestjs/config'; +import { ExtractJwt, Strategy } from 'passport-jwt'; import { JwtPayload, ReqUserPayload } from '@src/common/types/type'; import { User } from '@src/infrastructure'; +import { JWT_STRATEGY_TOKEN } from './strategy.token'; @Injectable() export class JwtStrategy extends PassportStrategy( diff --git a/src/modules/users/users.module.ts b/src/modules/users/users.module.ts index 83f8798..8bbb03c 100644 --- a/src/modules/users/users.module.ts +++ b/src/modules/users/users.module.ts @@ -1,12 +1,12 @@ import { Module } from '@nestjs/common'; -import { UsersController } from './users.controller'; -import { UsersService } from './users.service'; import { MongooseModule } from '@nestjs/mongoose'; -import { JwtStrategy } from './guards/strategy'; import { Folder, FolderSchema, User, UserSchema } from '@src/infrastructure'; -import { UsersRepository } from './users.repository'; import { AuthModule } from '../auth/auth.module'; import { FolderRepository } from '../folders/folders.repository'; +import { JwtStrategy } from './guards/strategy'; +import { UsersController } from './users.controller'; +import { UsersRepository } from './users.repository'; +import { UsersService } from './users.service'; @Module({ imports: [ diff --git a/src/modules/users/users.repository.ts b/src/modules/users/users.repository.ts index 438161e..f7b449f 100644 --- a/src/modules/users/users.repository.ts +++ b/src/modules/users/users.repository.ts @@ -1,7 +1,7 @@ import { Injectable } from '@nestjs/common'; import { InjectModel } from '@nestjs/mongoose'; -import { User } from '@src/infrastructure'; import { Model } from 'mongoose'; +import { User } from '@src/infrastructure'; @Injectable() export class UsersRepository { diff --git a/src/modules/users/users.service.ts b/src/modules/users/users.service.ts index a346cd5..ff287e2 100644 --- a/src/modules/users/users.service.ts +++ b/src/modules/users/users.service.ts @@ -1,6 +1,6 @@ import { Injectable } from '@nestjs/common'; -import { FolderType } from '@src/infrastructure/database/types/folder-type.enum'; import { JwtPayload } from 'src/common/types/type'; +import { FolderType } from '@src/infrastructure/database/types/folder-type.enum'; import { AuthService } from '../auth/auth.service'; import { FolderRepository } from '../folders/folders.repository'; import { CreateUserDto } from './dto'; diff --git a/test/app.e2e-spec.ts b/test/app.e2e-spec.ts index 50cda62..255e1b0 100644 --- a/test/app.e2e-spec.ts +++ b/test/app.e2e-spec.ts @@ -1,6 +1,8 @@ -import { Test, TestingModule } from '@nestjs/testing'; -import { INestApplication } from '@nestjs/common'; import * as request from 'supertest'; + +import { INestApplication } from '@nestjs/common'; +import { Test, TestingModule } from '@nestjs/testing'; + import { AppModule } from './../src/app.module'; describe('AppController (e2e)', () => {