Skip to content

Commit

Permalink
refactor: 기존 코드를 v1로 이전하고 절대경로 import 사용
Browse files Browse the repository at this point in the history
  • Loading branch information
scarf005 committed Jul 18, 2023
1 parent 7d2c039 commit 3b4418e
Show file tree
Hide file tree
Showing 91 changed files with 197 additions and 196 deletions.
2 changes: 1 addition & 1 deletion backend/src/app-data-source.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { DataSource, DataSourceOptions } from 'typeorm';
import { connectOption } from './config';
import { connectOption } from '~/config';

export const option: DataSourceOptions = {
type: 'mysql',
Expand Down
16 changes: 8 additions & 8 deletions backend/src/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@ import express from 'express';
import passport from 'passport';
import swaggerJsdoc from 'swagger-jsdoc';
import swaggerUi from 'swagger-ui-express';
import jipDataSource from './app-data-source';
import { FtAuthentication, FtStrategy, JwtStrategy } from './auth/auth.strategy';
import { connectMode } from './config';
import router from './routes';
import swaggerOptions from './swagger/swagger';
import errorConverter from './utils/error/errorConverter';
import errorHandler from './utils/error/errorHandler';
import { logger, morganMiddleware } from './utils/logger';
import { FtAuthentication, FtStrategy, JwtStrategy } from '~/v1/auth/auth.strategy';
import swaggerOptions from '~/v1/swagger/swagger';
import errorConverter from '~/v1/utils/error/errorConverter';
import errorHandler from '~/v1/utils/error/errorHandler';
import { logger, morganMiddleware } from '~/v1/utils/logger';
import { connectMode } from '~/config';
import jipDataSource from '~/app-data-source';
import router from './v1/routes';

const app: express.Application = express();

Expand Down
4 changes: 2 additions & 2 deletions backend/src/mysql.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { FieldPacket } from 'mysql2';
import mysql from 'mysql2/promise';
import { connectOption } from './config';
import { logger } from './utils/logger';
import { logger } from '~/v1/utils/logger';
import { connectOption } from '~/config';

export const DBError = 'DB error';

Expand Down
8 changes: 4 additions & 4 deletions backend/src/server.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { createHttpTerminator } from 'http-terminator';
import { logger } from '~/v1/utils/logger';
import scheduler from '~/v1/utils/scheduler';
import { gracefulTerminationTimeout } from '~/config';
import jipDataSource from '~/app-data-source';
import app from './app';
import jipDataSource from './app-data-source';
import { logger } from './utils/logger';
import scheduler from './utils/scheduler';
import { gracefulTerminationTimeout } from './config';

const port = '3000';

Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@ import * as bcrypt from 'bcrypt';
import { NextFunction, Request, Response } from 'express';
import * as status from 'http-status';
import { randomUUID } from 'node:crypto';
import * as errorCode from '~/v1/utils/error/errorCode';
import ErrorResponse from '~/v1/utils/error/errorResponse';
import { logger } from '~/v1/utils/logger';
import { oauth42ApiOption, oauthUrlOption } from '~/config';
import UsersService from '~/v1/users/users.service';
import * as models from '../DTO/users.model';
import { oauth42ApiOption, oauthUrlOption } from '../config';
import { updateSlackIdByUserId } from '../slack/slack.service';
import UsersService from '../users/users.service';
import * as errorCode from '../utils/error/errorCode';
import ErrorResponse from '../utils/error/errorResponse';
import { logger } from '../utils/logger';
import * as authJwt from './auth.jwt';
import * as authService from './auth.service';
import { role } from './auth.type';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Request, Response } from 'express';
import * as jwt from 'jsonwebtoken';
import { jwtOption } from '~/config';
import { User } from '../DTO/users.model';
import { jwtOption } from '../config';

/**
* User 정보를 가지고 token 만들기
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { ResultSetHeader } from 'mysql2';
import { executeQuery } from '../mysql';
import { executeQuery } from '~/mysql';
import { role } from './auth.type';

// eslint-disable-next-line import/prefer-default-export
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Request } from 'express';
import { Strategy as FortyTwoStrategy } from 'passport-42';
import { ExtractJwt, Strategy as JWTStrategy, VerifiedCallback } from 'passport-jwt';
import { jwtOption, oauth42ApiOption, oauthUrlOption } from '../config';
import { jwtOption, oauth42ApiOption, oauthUrlOption } from '~/config';

const credentials = {
clientID: oauth42ApiOption.id,
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import { Request, Response } from 'express';
import * as status from 'http-status';
import { verify } from 'jsonwebtoken';
import * as errorCode from '~/v1/utils/error/errorCode';
import ErrorResponse from '~/v1/utils/error/errorResponse';
import { logger } from '~/v1/utils/logger';
import { jwtOption } from '~/config';
import UsersService from '~/v1/users/users.service';
import { User } from '../DTO/users.model';
import { jwtOption } from '../config';
import UsersService from '../users/users.service';
import * as errorCode from '../utils/error/errorCode';
import ErrorResponse from '../utils/error/errorResponse';
import { logger } from '../utils/logger';
import { role } from './auth.type';

const usersService = new UsersService();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import { Request, Response } from 'express';
import * as status from 'http-status';
import { verify } from 'jsonwebtoken';
import * as errorCode from '~/v1/utils/error/errorCode';
import ErrorResponse from '~/v1/utils/error/errorResponse';
import { logger } from '~/v1/utils/logger';
import { jwtOption } from '~/config';
import UsersService from '~/v1/users/users.service';
import { User } from '../DTO/users.model';
import { jwtOption } from '../config';
import UsersService from '../users/users.service';
import * as errorCode from '../utils/error/errorCode';
import ErrorResponse from '../utils/error/errorResponse';
import { logger } from '../utils/logger';
import { role } from './auth.type';

const usersService = new UsersService();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ import {
NextFunction, Request, Response,
} from 'express';
import * as status from 'http-status';
import * as parseCheck from './utils/parseCheck';
import * as bookInfoReviewsService from '../service/bookInfoReviews.service';
import * as errorCheck from './utils/errorCheck';
import * as parseCheck from './utils/parseCheck';

export const getBookInfoReviewsPage = async (
req: Request,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import * as errorCode from '../../../utils/error/errorCode';
import ErrorResponse from '../../../utils/error/errorResponse';
import * as errorCode from '~/v1/utils/error/errorCode';
import ErrorResponse from '~/v1/utils/error/errorResponse';

export const bookInfoParseCheck = (
bookInfoId : string,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { executeQuery } from '../../mysql';
import { executeQuery } from '~/mysql';

export const getBookinfoReviewsPageNoOffset = async (bookInfoId: number, reviewsId: number, sort: 'asc' | 'desc', limit: number) => {
const bookInfoIdQuery = (Number.isNaN(bookInfoId)) ? '' : `AND reviews.bookInfoId = ${bookInfoId}`;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { QueryRunner, Repository } from 'typeorm';
import jipDataSource from '../app-data-source';
import Likes from '../entity/entities/Likes';
import Likes from '~/entity/entities/Likes';
import jipDataSource from '~/app-data-source';

class LikesRepository extends Repository<Likes> {
constructor(transactionQueryRunner?: QueryRunner) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import * as status from 'http-status';
import { pool } from '../mysql';
import { pool } from '~/mysql';
import ErrorResponse from '~/v1/utils/error/errorResponse';
import * as BooksController from './books.controller';
import ErrorResponse from '../utils/error/errorResponse';

describe('BooksController', () => {
afterAll(() => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@ import {
NextFunction, Request, RequestHandler, Response,
} from 'express';
import * as status from 'http-status';
import * as errorCode from '../utils/error/errorCode';
import ErrorResponse from '../utils/error/errorResponse';
import isNullish from '../utils/isNullish';
import { logger } from '../utils/logger';
import * as errorCode from '~/v1/utils/error/errorCode';
import ErrorResponse from '~/v1/utils/error/errorResponse';
import isNullish from '~/v1/utils/isNullish';
import { logger } from '~/v1/utils/logger';
import * as BooksService from './books.service';
import * as types from './books.type';
import LikesService from './likes.service';
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
import { Like, QueryRunner, Repository } from 'typeorm';
import * as Status from 'http-status';
import jipDataSource from '../app-data-source';
import { VSearchBook } from '../entity/entities/VSearchBook';
import { VSearchBook } from '~/entity/entities/VSearchBook';
import * as errorCode from '~/v1/utils/error/errorCode';
import Book from '~/entity/entities/Book';
import BookInfo from '~/entity/entities/BookInfo';
import Lending from '~/entity/entities/Lending';
import Category from '~/entity/entities/Category';
import User from '~/entity/entities/User';
import ErrorResponse from '~/v1/utils/error/errorResponse';
import jipDataSource from '~/app-data-source';
import {
CreateBookInfo, LendingBookList, UpdateBook, UpdateBookInfo,
} from './books.type';
import * as errorCode from '../utils/error/errorCode';
import Book from '../entity/entities/Book';
import BookInfo from '../entity/entities/BookInfo';
import Lending from '../entity/entities/Lending';
import Category from '../entity/entities/Category';
import User from '../entity/entities/User';
import ErrorResponse from '../utils/error/errorResponse';

class BooksRepository extends Repository<Book> {
private readonly searchBook: Repository<VSearchBook>;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import jipDataSource from '~/app-data-source';
import * as BooksService from './books.service';
import { CreateBookInfo } from './books.type';
import jipDataSource from '../app-data-source';

describe('BooksService', () => {
beforeAll(async () => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
/* eslint-disable prefer-regex-literals */
/* eslint-disable prefer-destructuring */
import axios from 'axios';
import jipDataSource from '../app-data-source';
import { nationalIsbnApiKey, naverBookApiOption } from '../config';
import { executeQuery } from '../mysql';
import * as errorCode from '../utils/error/errorCode';
import { logger } from '../utils/logger';
import { StringRows } from '../utils/types';
import { nationalIsbnApiKey, naverBookApiOption } from '~/config';
import { executeQuery } from '~/mysql';
import * as errorCode from '~/v1/utils/error/errorCode';
import { logger } from '~/v1/utils/logger';
import { StringRows } from '~/v1/utils/types';
import jipDataSource from '~/app-data-source';
import * as models from './books.model';
import BooksRepository from './books.repository';
import {
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import * as errorCode from '~/v1/utils/error/errorCode';
import jipDataSource from '~/app-data-source';
import LikesRepository from './Likes.repository';
import * as errorCode from '../utils/error/errorCode';
import jipDataSource from '../app-data-source';

export default class LikesService {
private readonly likesRepository : LikesRepository;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@ import {
NextFunction, Request, Response,
} from 'express';
import * as status from 'http-status';
import ErrorResponse from '~/v1/utils/error/errorResponse';
import { logger } from '~/v1/utils/logger';
import * as errorCode from '~/v1/utils/error/errorCode';
import * as historiesService from './histories.service';
import ErrorResponse from '../utils/error/errorResponse';
import { logger } from '../utils/logger';
import * as errorCode from '../utils/error/errorCode';

// eslint-disable-next-line import/prefer-default-export
export const histories = async (
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { QueryRunner, Repository } from 'typeorm';
import VHistories from '../entity/entities/VHistories';
import jipDataSource from '../app-data-source';
import VHistories from '~/entity/entities/VHistories';
import jipDataSource from '~/app-data-source';

class HistoriesRepository extends Repository<VHistories> {
constructor(transactionQueryRunner?: QueryRunner) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Like } from 'typeorm';
import UsersRepository from '~/v1/users/users.repository';
import { Meta } from '../DTO/common.interface';
import HistoriesRepository from './histories.repository';
import UsersRepository from '../users/users.repository';

// eslint-disable-next-line import/prefer-default-export
export const getHistories = async (
Expand Down
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import * as status from 'http-status';
import { pool } from '../mysql';
import { pool } from '~/mysql';
import * as lendingsController from './lendings.controller';

describe('LendingsController', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ import {
NextFunction, Request, RequestHandler, Response,
} from 'express';
import * as status from 'http-status';
import * as errorCode from '../utils/error/errorCode';
import ErrorResponse from '../utils/error/errorResponse';
import { logger } from '../utils/logger';
import * as errorCode from '~/v1/utils/error/errorCode';
import ErrorResponse from '~/v1/utils/error/errorResponse';
import { logger } from '~/v1/utils/logger';
import * as lendingsService from './lendings.service';

export const create: RequestHandler = async (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@ import {
IsNull, MoreThan, QueryRunner, Repository, UpdateResult,
} from 'typeorm';
import { QueryDeepPartialEntity } from 'typeorm/query-builder/QueryPartialEntity';
import User from '../entity/entities/User';
import jipDataSource from '../app-data-source';
import Lending from '../entity/entities/Lending';
import VUserLending from '../entity/entities/VUserLending';
import Book from '../entity/entities/Book';
import Reservation from '../entity/entities/Reservation';
import VLending from '../entity/entities/VLending';
import { formatDate } from '../utils/dateFormat';
import User from '~/entity/entities/User';
import jipDataSource from '~/app-data-source';
import Lending from '~/entity/entities/Lending';
import VUserLending from '~/entity/entities/VUserLending';
import Book from '~/entity/entities/Book';
import Reservation from '~/entity/entities/Reservation';
import VLending from '~/entity/entities/VLending';
import { formatDate } from '~/v1/utils/dateFormat';

class LendingRepository extends Repository<Lending> {
private readonly userRepo: Repository<User>;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { pool } from '../mysql';
import { pool } from '~/mysql';
import * as lendingsService from './lendings.service';

describe('LendingsService', () => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
/* eslint-disable prefer-destructuring */
/* eslint-disable consistent-return */
import { IsNull, Like } from 'typeorm';
import { formatDate } from '~/v1/utils/dateFormat';
import * as errorCode from '~/v1/utils/error/errorCode';
import jipDataSource from '~/app-data-source';
import UsersRepository from '~/v1/users/users.repository';
import { publishMessage } from '../slack/slack.service';
import { Meta } from '../DTO/common.interface';
import { formatDate } from '../utils/dateFormat';
import * as errorCode from '../utils/error/errorCode';
import UsersRepository from '../users/users.repository';
import LendingRepository from './lendings.repository';
import jipDataSource from '../app-data-source';

export const create = async (
userId: number,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ import {
NextFunction,
Request, Response,
} from 'express';
import ErrorResponse from '../utils/error/errorResponse';
import * as errorCode from '../utils/error/errorCode';
import ErrorResponse from '~/v1/utils/error/errorResponse';
import * as errorCode from '~/v1/utils/error/errorCode';

const wrapAsyncController = (fn: Function) => (req: Request, res: Response, next: NextFunction) => {
fn(req, res, next)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { executeQuery, makeExecuteQuery, pool } from '../mysql';
import { executeQuery, makeExecuteQuery, pool } from '~/mysql';
import { publishMessage } from '../slack/slack.service';

const succeedReservation = async (reservation: {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import * as status from 'http-status';
import { pool } from '../mysql';
import { pool } from '~/mysql';
import * as reservationsController from './reservations.controller';

describe('ReservationsController', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@ import {
NextFunction, Request, RequestHandler, Response,
} from 'express';
import * as status from 'http-status';
import ErrorResponse from '~/v1/utils/error/errorResponse';
import { logger } from '~/v1/utils/logger';
import * as errorCode from '~/v1/utils/error/errorCode';
import * as userUtils from '~/v1/users/users.utils';
import * as reservationsService from './reservations.service';
import ErrorResponse from '../utils/error/errorResponse';
import { logger } from '../utils/logger';
import * as errorCode from '../utils/error/errorCode';
import * as userUtils from '../users/users.utils';

export const create: RequestHandler = async (
req: Request,
Expand Down
Loading

0 comments on commit 3b4418e

Please sign in to comment.