Skip to content

Commit

Permalink
feat: realworld mysql
Browse files Browse the repository at this point in the history
  • Loading branch information
khuongln-1346 committed Nov 22, 2024
1 parent 464f0b9 commit b74a621
Show file tree
Hide file tree
Showing 26 changed files with 27 additions and 41 deletions.
2 changes: 1 addition & 1 deletion apps/realworld-api/src/api/article/article.module.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Module } from '@nestjs/common';
import { TypeOrmModule } from '@nestjs/typeorm';
import { ArticleEntity, TagEntity, UserEntity } from '@repo/database-typeorm';
import { ArticleEntity, TagEntity, UserEntity } from '@repo/mysql-typeorm';
import { ArticleController } from './article.controller';
import { ArticleService } from './article.service';
import { CommentModule } from './comment/comment.module';
Expand Down
2 changes: 1 addition & 1 deletion apps/realworld-api/src/api/article/article.service.spec.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Test, TestingModule } from '@nestjs/testing';
import { getRepositoryToken } from '@nestjs/typeorm';
import { ArticleEntity, TagEntity, UserEntity } from '@repo/database-typeorm';
import { ArticleEntity, TagEntity, UserEntity } from '@repo/mysql-typeorm';
import { I18nService } from 'nestjs-i18n';
import { Repository } from 'typeorm';
import { ArticleService } from './article.service';
Expand Down
2 changes: 1 addition & 1 deletion apps/realworld-api/src/api/article/article.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { ErrorCode } from '@/constants/error-code.constant';
import { Injectable, Logger, NotFoundException } from '@nestjs/common';
import { InjectRepository } from '@nestjs/typeorm';
import { paginate } from '@repo/api/utils/offset-pagination';
import { ArticleEntity, TagEntity, UserEntity } from '@repo/database-typeorm';
import { ArticleEntity, TagEntity, UserEntity } from '@repo/mysql-typeorm';
import { I18nService } from 'nestjs-i18n';
import slugify from 'slugify';
import { In, Repository } from 'typeorm';
Expand Down
2 changes: 1 addition & 1 deletion apps/realworld-api/src/api/article/article.util.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { ArticleEntity, UserEntity } from '@repo/database-typeorm';
import { ArticleEntity, UserEntity } from '@repo/mysql-typeorm';
import { ProfileDto } from '../profile/dto/profile.dto';
import { ArticleDto } from './dto/article.dto';

Expand Down
6 changes: 1 addition & 5 deletions apps/realworld-api/src/api/article/comment/comment.module.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
import { Module } from '@nestjs/common';
import { TypeOrmModule } from '@nestjs/typeorm';
import {
ArticleEntity,
CommentEntity,
UserEntity,
} from '@repo/database-typeorm';
import { ArticleEntity, CommentEntity, UserEntity } from '@repo/mysql-typeorm';
import { CommentController } from './comment.controller';
import { CommentService } from './comment.service';

Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
import { Test, TestingModule } from '@nestjs/testing';
import { getRepositoryToken } from '@nestjs/typeorm';
import {
ArticleEntity,
CommentEntity,
UserEntity,
} from '@repo/database-typeorm';
import { ArticleEntity, CommentEntity, UserEntity } from '@repo/mysql-typeorm';
import { Repository } from 'typeorm';
import { CommentService } from './comment.service';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,7 @@ import { ErrorCode } from '@/constants/error-code.constant';
import { Injectable } from '@nestjs/common';
import { InjectRepository } from '@nestjs/typeorm';
import { ValidationException } from '@repo/api';
import {
ArticleEntity,
CommentEntity,
UserEntity,
} from '@repo/database-typeorm';
import { ArticleEntity, CommentEntity, UserEntity } from '@repo/mysql-typeorm';
import { Repository } from 'typeorm';
import { CommentListResDto } from './dto/comment-list.dto';
import { CommentResDto } from './dto/comment.dto';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Module } from '@nestjs/common';
import { TypeOrmModule } from '@nestjs/typeorm';
import { ArticleEntity, UserEntity } from '@repo/database-typeorm';
import { ArticleEntity, UserEntity } from '@repo/mysql-typeorm';
import { FavoriteController } from './favorite.controller';
import { FavoriteService } from './favorite.service';

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Test, TestingModule } from '@nestjs/testing';
import { getRepositoryToken } from '@nestjs/typeorm';
import { ArticleEntity, UserEntity } from '@repo/database-typeorm';
import { ArticleEntity, UserEntity } from '@repo/mysql-typeorm';
import { Repository } from 'typeorm';
import { FavoriteService } from './favorite.service';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { ErrorCode } from '@/constants/error-code.constant';
import { Injectable } from '@nestjs/common';
import { InjectRepository } from '@nestjs/typeorm';
import { ValidationException } from '@repo/api';
import { ArticleEntity, UserEntity } from '@repo/database-typeorm';
import { ArticleEntity, UserEntity } from '@repo/mysql-typeorm';
import { Repository } from 'typeorm';
import { toArticleDto } from '../article.util';
import { ArticleResDto } from '../dto/article.dto';
Expand Down
2 changes: 1 addition & 1 deletion apps/realworld-api/src/api/auth/auth.module.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Module } from '@nestjs/common';
import { JwtModule } from '@nestjs/jwt';
import { TypeOrmModule } from '@nestjs/typeorm';
import { UserEntity } from '@repo/database-typeorm';
import { UserEntity } from '@repo/mysql-typeorm';
import { AuthController } from './auth.controller';
import { AuthService } from './auth.service';

Expand Down
2 changes: 1 addition & 1 deletion apps/realworld-api/src/api/auth/auth.service.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { ConfigService } from '@nestjs/config';
import { JwtService } from '@nestjs/jwt';
import { Test, TestingModule } from '@nestjs/testing';
import { getRepositoryToken } from '@nestjs/typeorm';
import { UserEntity } from '@repo/database-typeorm';
import { UserEntity } from '@repo/mysql-typeorm';
import { Repository } from 'typeorm';
import { AuthService } from './auth.service';

Expand Down
2 changes: 1 addition & 1 deletion apps/realworld-api/src/api/auth/auth.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { Injectable, UnauthorizedException } from '@nestjs/common';
import { ConfigService } from '@nestjs/config';
import { JwtService } from '@nestjs/jwt';
import { InjectRepository } from '@nestjs/typeorm';
import { UserEntity } from '@repo/database-typeorm';
import { UserEntity } from '@repo/mysql-typeorm';
import { verifyPassword } from '@repo/nest-common';
import { Repository } from 'typeorm';
import { UserResDto } from '../user/dto/user.dto';
Expand Down
2 changes: 1 addition & 1 deletion apps/realworld-api/src/api/profile/profile.module.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Module } from '@nestjs/common';
import { TypeOrmModule } from '@nestjs/typeorm';
import { UserEntity, UserFollowsEntity } from '@repo/database-typeorm';
import { UserEntity, UserFollowsEntity } from '@repo/mysql-typeorm';
import { ProfileController } from './profile.controller';
import { ProfileService } from './profile.service';

Expand Down
4 changes: 2 additions & 2 deletions apps/realworld-api/src/api/profile/profile.service.spec.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Test, TestingModule } from '@nestjs/testing';
import { getRepositoryToken } from '@nestjs/typeorm';
import { UserEntity } from '@repo/database-typeorm';
import { UserFollowsEntity } from '@repo/database-typeorm/entities/user-follows.entity';
import { UserEntity } from '@repo/mysql-typeorm';
import { UserFollowsEntity } from '@repo/mysql-typeorm/entities/user-follows.entity';
import { Repository } from 'typeorm';
import { ProfileService } from './profile.service';

Expand Down
2 changes: 1 addition & 1 deletion apps/realworld-api/src/api/profile/profile.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { ErrorCode } from '@/constants/error-code.constant';
import { Injectable, Logger } from '@nestjs/common';
import { InjectRepository } from '@nestjs/typeorm';
import { ValidationException } from '@repo/api';
import { UserEntity, UserFollowsEntity } from '@repo/database-typeorm';
import { UserEntity, UserFollowsEntity } from '@repo/mysql-typeorm';
import { Repository } from 'typeorm';
import { ProfileDto, ProfileResDto } from './dto/profile.dto';

Expand Down
2 changes: 1 addition & 1 deletion apps/realworld-api/src/api/tag/tag.module.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Module } from '@nestjs/common';
import { TypeOrmModule } from '@nestjs/typeorm';
import { TagEntity } from '@repo/database-typeorm';
import { TagEntity } from '@repo/mysql-typeorm';
import { TagController } from './tag.controller';
import { TagService } from './tag.service';

Expand Down
2 changes: 1 addition & 1 deletion apps/realworld-api/src/api/tag/tag.service.spec.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Test, TestingModule } from '@nestjs/testing';
import { getRepositoryToken } from '@nestjs/typeorm';
import { TagEntity } from '@repo/database-typeorm';
import { TagEntity } from '@repo/mysql-typeorm';
import { Repository } from 'typeorm';
import { TagService } from './tag.service';

Expand Down
2 changes: 1 addition & 1 deletion apps/realworld-api/src/api/tag/tag.service.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Injectable } from '@nestjs/common';
import { InjectRepository } from '@nestjs/typeorm';
import { TagEntity } from '@repo/database-typeorm';
import { TagEntity } from '@repo/mysql-typeorm';
import { Repository } from 'typeorm';
import { TagListResDto } from './dto/tag-list.dto';

Expand Down
2 changes: 1 addition & 1 deletion apps/realworld-api/src/api/user/user.module.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Module } from '@nestjs/common';
import { TypeOrmModule } from '@nestjs/typeorm';
import { UserEntity } from '@repo/database-typeorm';
import { UserEntity } from '@repo/mysql-typeorm';
import { AuthModule } from '../auth/auth.module';
import { UserController } from './user.controller';
import { UserService } from './user.service';
Expand Down
2 changes: 1 addition & 1 deletion apps/realworld-api/src/api/user/user.service.spec.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Test, TestingModule } from '@nestjs/testing';
import { getRepositoryToken } from '@nestjs/typeorm';
import { UserEntity } from '@repo/database-typeorm';
import { UserEntity } from '@repo/mysql-typeorm';
import { Repository } from 'typeorm';
import { AuthService } from '../auth/auth.service';
import { UserService } from './user.service';
Expand Down
2 changes: 1 addition & 1 deletion apps/realworld-api/src/api/user/user.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { ErrorCode } from '@/constants/error-code.constant';
import { Injectable } from '@nestjs/common';
import { InjectRepository } from '@nestjs/typeorm';
import { ValidationException } from '@repo/api';
import { UserEntity } from '@repo/database-typeorm';
import { UserEntity } from '@repo/mysql-typeorm';
import { Repository } from 'typeorm';
import { AuthService } from '../auth/auth.service';
import { CreateUserReqDto } from './dto/create-user.dto';
Expand Down
5 changes: 2 additions & 3 deletions apps/realworld-api/src/app.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { MiddlewareConsumer, Module, NestModule } from '@nestjs/common';
import { ConfigModule, ConfigService } from '@nestjs/config';
import { TypeOrmModule } from '@nestjs/typeorm';
import { appConfig, Environment } from '@repo/api';
import { databaseConfig } from '@repo/database-typeorm';
import { databaseConfig } from '@repo/mysql-typeorm';
import {
AsyncContextProvider,
FastifyPinoLogger,
Expand All @@ -21,8 +21,7 @@ import authConfig from './api/auth/config/auth.config';
import { AppController } from './app.controller';
import { AppService } from './app.service';
import { AllConfigType } from './config/config.type';
// import { TypeOrmConfigService } from './database/mysql-typeorm-config.service'; // Uncomment this line if you are using MySQL
import { TypeOrmConfigService } from './database/typeorm-config.service';
import { TypeOrmConfigService } from './database/mysql-typeorm-config.service';

const configModule = ConfigModule.forRoot({
isGlobal: true,
Expand Down
2 changes: 1 addition & 1 deletion apps/realworld-api/src/config/config.type.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { AuthConfig } from '@/api/auth/config/auth-config.type';
import { AppConfig } from '@repo/api';
import { DatabaseConfig } from '@repo/database-typeorm';
import { DatabaseConfig } from '@repo/mysql-typeorm';

export type AllConfigType = {
app: AppConfig;
Expand Down
2 changes: 1 addition & 1 deletion apps/realworld-api/src/database/typeorm-config.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { AllConfigType } from '@/config/config.type';
import { Injectable } from '@nestjs/common';
import { ConfigService } from '@nestjs/config';
import { TypeOrmModuleOptions, TypeOrmOptionsFactory } from '@nestjs/typeorm';
import { TypeOrmCustomLogger } from '@repo/database-typeorm';
import { TypeOrmCustomLogger } from '@repo/mysql-typeorm';
import { join } from 'path';

@Injectable()
Expand Down
1 change: 0 additions & 1 deletion apps/realworld-api/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
"@/guards/*": ["src/guards/*"],
"@/interceptors/*": ["src/interceptors/*"],
"@/utils/*": ["src/utils/*"]
// "@repo/database-typeorm": ["node_modules/@repo/mysql-typeorm"], // Uncomment this line if you are using MySQL
}
}
}

0 comments on commit b74a621

Please sign in to comment.