Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Husky & Prettier Linter 적용 #104

Merged
merged 6 commits into from
Sep 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/bin/bash

npx prettier --write ./src
16 changes: 14 additions & 2 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -1,4 +1,16 @@
{
"singleQuote": true,
"trailingComma": "all"
}
"trailingComma": "all",
"plugins": ["@trivago/prettier-plugin-sort-imports"],
"importOrder": [
"^@nestjs/(.*)$",
"<THIRD_PARTY_MODULES>",
"^@src/(.*)$",
"^[./]"
],
"importOrderSortSpecifiers": true,
"importOrderParserPlugins": [
"typescript",
"[\"decorators-legacy\", { \"decoratorsBeforeExport\": true }]"
]
}
5 changes: 4 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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",
Expand All @@ -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",
Expand Down
85 changes: 84 additions & 1 deletion pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion src/app.controller.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
// Nest Packagess
import { Controller, Get } from '@nestjs/common';

// Custom Packages
import { AppService } from './app.service';

Expand Down
3 changes: 1 addition & 2 deletions src/app.module.ts
Original file line number Diff line number Diff line change
@@ -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';
Expand All @@ -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: [
Expand Down
2 changes: 1 addition & 1 deletion src/bootstrap.ts
Original file line number Diff line number Diff line change
@@ -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();
Expand Down
2 changes: 1 addition & 1 deletion src/common/decorators/getUser.decorator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/common/filter/base.filter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';

Expand Down
1 change: 1 addition & 0 deletions src/common/types/type.d.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { Types } from 'mongoose';

// Exception Payload
export type ExceptionPayload = {
code?: string;
Expand Down
1 change: 1 addition & 0 deletions src/handler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
2 changes: 1 addition & 1 deletion src/infrastructure/aws-lambda/aws-lambda.service.ts
Original file line number Diff line number Diff line change
@@ -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()
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { Prop, Schema, SchemaFactory } from '@nestjs/mongoose';
import { HydratedDocument, Schema as MongooseSchema } from 'mongoose';

import { BaseDocument } from './base.schema';

@Schema({
Expand Down
4 changes: 2 additions & 2 deletions src/infrastructure/database/schema/post.schema.ts
Original file line number Diff line number Diff line change
@@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion src/modules/auth/auth.module.ts
Original file line number Diff line number Diff line change
@@ -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: [
Expand Down
3 changes: 1 addition & 2 deletions src/modules/classification/classification.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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: [
Expand Down
2 changes: 1 addition & 1 deletion src/modules/classification/classification.repository.ts
Original file line number Diff line number Diff line change
@@ -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()
Expand Down
6 changes: 2 additions & 4 deletions src/modules/classification/classification.service.ts
Original file line number Diff line number Diff line change
@@ -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()
Expand Down
Loading