Skip to content

Commit

Permalink
refactor: move common files under common dir
Browse files Browse the repository at this point in the history
  • Loading branch information
solufa committed Jul 9, 2024
1 parent 57ad2be commit f81cc39
Show file tree
Hide file tree
Showing 40 changed files with 51 additions and 58 deletions.
1 change: 1 addition & 0 deletions client/common
4 changes: 2 additions & 2 deletions client/features/tasks/TaskList.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import type { TaskDto } from 'api/@types/task';
import { labelValidator } from 'api/@validators/task';
import type { TaskDto } from 'common/types/task';
import { labelValidator } from 'common/validators/task';
import { Loading } from 'components/loading/Loading';
import { usePickedLastMsg } from 'features/ws/AuthedWebSocket';
import { useAlert } from 'hooks/useAlert';
Expand Down
4 changes: 2 additions & 2 deletions client/features/ws/AuthedWebSocket.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { IS_PROD, WS_PATH, WS_PING, WS_PONG } from 'api/@constants';
import type { WebSocketData } from 'api/@types/websocket';
import { IS_PROD, WS_PATH, WS_PING, WS_PONG } from 'common/constants';
import type { WebSocketData } from 'common/types/websocket';
import { atom, useAtom } from 'jotai';
import { useEffect, useRef } from 'react';
import useWebSocket from 'react-use-websocket';
Expand Down
2 changes: 1 addition & 1 deletion client/hooks/useUser.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { UserDto } from 'api/@types/user';
import type { UserDto } from 'common/types/user';
import { atom, useAtom } from 'jotai';
import { useCallback } from 'react';

Expand Down
2 changes: 1 addition & 1 deletion client/layouts/Layout.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { UserDto } from 'api/@types/user';
import type { UserDto } from 'common/types/user';
import { Loading } from 'components/loading/Loading';
import { useLoading } from 'components/loading/useLoading';
import { AuthedWebSocket } from 'features/ws/AuthedWebSocket';
Expand Down
4 changes: 2 additions & 2 deletions client/layouts/basicHeader/BasicHeader.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { AccountSettings } from '@aws-amplify/ui-react';
import { APP_NAME } from 'api/@constants';
import type { UserDto } from 'api/@types/user';
import { signOut } from 'aws-amplify/auth';
import { APP_NAME } from 'common/constants';
import type { UserDto } from 'common/types/user';
import { Spacer } from 'components/Spacer';
import { HumanIcon } from 'components/icons/HumanIcon';
import { Modal, ModalBody, ModalFooter, ModalHeader } from 'components/modal/Modal';
Expand Down
2 changes: 1 addition & 1 deletion client/pages/_app.page.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { Authenticator, translations } from '@aws-amplify/ui-react';
import '@aws-amplify/ui-react/styles.css';
import { APP_NAME } from 'api/@constants';
import { Amplify } from 'aws-amplify';
import { I18n } from 'aws-amplify/utils';
import { APP_NAME } from 'common/constants';
import { AuthLoader } from 'features/auth/AuthLoader';
import type { AppProps } from 'next/app';
import dynamic from 'next/dynamic';
Expand Down
2 changes: 1 addition & 1 deletion client/pages/_document.page.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { APP_NAME } from 'api/@constants';
import { APP_NAME } from 'common/constants';
import { Head, Html, Main, NextScript } from 'next/document';
import { staticPath } from 'utils/$path';

Expand Down
2 changes: 1 addition & 1 deletion client/pages/login/index.page.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Authenticator } from '@aws-amplify/ui-react';
import { APP_NAME } from 'api/@constants';
import { signUp } from 'aws-amplify/auth';
import { APP_NAME } from 'common/constants';
import { Spacer } from 'components/Spacer';
import { Loading } from 'components/loading/Loading';
import { useUser } from 'hooks/useUser';
Expand Down
2 changes: 1 addition & 1 deletion server/api/private/hooks.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { UserDto } from 'api/@types/user';
import type { UserDto } from 'common/types/user';
import { userUseCase } from 'domain/user/useCase/userUseCase';
import type { JwtUser } from 'service/types';
import { defineHooks } from './$relay';
Expand Down
2 changes: 1 addition & 1 deletion server/api/private/me/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import type { UserDto } from 'api/@types/user';
import type { DefineMethods } from 'aspida';
import type { UserDto } from 'common/types/user';

export type Methods = DefineMethods<{
get: {
Expand Down
2 changes: 1 addition & 1 deletion server/api/private/tasks/_taskId@string/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import type { TaskDto } from 'api/@types/task';
import type { DefineMethods } from 'aspida';
import type { TaskDto } from 'common/types/task';

export type Methods = DefineMethods<{
patch: {
Expand Down
2 changes: 1 addition & 1 deletion server/api/private/tasks/di/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import type { TaskDto } from 'api/@types/task';
import type { DefineMethods } from 'aspida';
import type { TaskDto } from 'common/types/task';

export type Methods = DefineMethods<{
get: {
Expand Down
4 changes: 2 additions & 2 deletions server/api/private/tasks/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import type { MaybeId } from 'api/@types/brandedId';
import type { TaskCreateVal, TaskDto, TaskUpdateDoneDto } from 'api/@types/task';
import type { DefineMethods } from 'aspida';
import type { MaybeId } from 'common/types/brandedId';
import type { TaskCreateVal, TaskDto, TaskUpdateDoneDto } from 'common/types/task';

export type Methods = DefineMethods<{
get: {
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { BRANDED_ID_NAMES } from 'api/@constants';
import type { BRANDED_ID_NAMES } from 'common/constants';
import type { z } from 'zod';

type IdName = (typeof BRANDED_ID_NAMES)[number];
Expand Down
2 changes: 1 addition & 1 deletion server/api/@types/task.ts → server/common/types/task.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { WS_TYPES } from 'api/@constants';
import type { WS_TYPES } from 'common/constants';
import type { DtoId, MaybeId } from './brandedId';

export type TaskDto = {
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
6 changes: 3 additions & 3 deletions server/domain/task/event/taskEvent.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { WS_TYPES } from 'api/@constants';
import { WS_TYPES } from 'common/constants';
import type {
TaskCreatedEvent,
TaskDeletedEvent,
TaskDto,
TaskUpdatedEvent,
} from 'api/@types/task';
import type { UserDto } from 'api/@types/user';
} from 'common/types/task';
import type { UserDto } from 'common/types/user';
import { websocket } from 'service/websocket';

export const taskEvent = {
Expand Down
2 changes: 1 addition & 1 deletion server/domain/task/model/taskEntity.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import type { MultipartFile } from '@fastify/multipart';
import type { TaskDto } from 'api/@types/task';
import type { TaskDto } from 'common/types/task';
import type { EntityId } from 'service/brandedId';
import type { S3PutParams } from 'service/s3Client';

Expand Down
6 changes: 3 additions & 3 deletions server/domain/task/model/taskMethod.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import type { TaskUpdateDoneDto } from 'api/@types/task';
import type { UserDto } from 'api/@types/user';
import { labelValidator } from 'api/@validators/task';
import assert from 'assert';
import type { TaskUpdateDoneDto } from 'common/types/task';
import type { UserDto } from 'common/types/user';
import { labelValidator } from 'common/validators/task';
import { brandedId } from 'service/brandedId';
import { s3 } from 'service/s3Client';
import { ulid } from 'ulid';
Expand Down
2 changes: 1 addition & 1 deletion server/domain/task/repository/taskQuery.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import type { Prisma, Task, User } from '@prisma/client';
import type { DtoId, MaybeId } from 'api/@types/brandedId';
import type { DtoId, MaybeId } from 'common/types/brandedId';
import { brandedId } from 'service/brandedId';
import { s3 } from 'service/s3Client';
import { depend } from 'velona';
Expand Down
2 changes: 1 addition & 1 deletion server/domain/task/service/taskValidator.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { multipartFileValidator } from 'api/$relay';
import type { TaskUpdateDoneDto } from 'api/@types/task';
import type { TaskUpdateDoneDto } from 'common/types/task';
import { brandedId } from 'service/brandedId';
import { z } from 'zod';
import type { TaskCreateServerVal } from '../model/taskEntity';
Expand Down
2 changes: 1 addition & 1 deletion server/domain/task/service/toTaskDto.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { TaskDto } from 'api/@types/task';
import type { TaskDto } from 'common/types/task';
import { brandedId } from 'service/brandedId';
import type { TaskEntity } from '../model/taskEntity';

Expand Down
6 changes: 3 additions & 3 deletions server/domain/task/useCase/taskUseCase.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import type { MaybeId } from 'api/@types/brandedId';
import type { TaskDto, TaskUpdateDoneDto } from 'api/@types/task';
import type { UserDto } from 'api/@types/user';
import type { MaybeId } from 'common/types/brandedId';
import type { TaskDto, TaskUpdateDoneDto } from 'common/types/task';
import type { UserDto } from 'common/types/user';
import { transaction } from 'service/prismaClient';
import { taskEvent } from '../event/taskEvent';
import type { TaskCreateServerVal } from '../model/taskEntity';
Expand Down
2 changes: 1 addition & 1 deletion server/domain/user/model/userEntity.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { UserDto } from 'api/@types/user';
import type { UserDto } from 'common/types/user';
import type { EntityId } from 'service/brandedId';

export type UserEntity = Omit<UserDto, 'id'> & { id: EntityId['user'] };
2 changes: 1 addition & 1 deletion server/domain/user/service/toUserDto.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { UserDto } from 'api/@types/user';
import type { UserDto } from 'common/types/user';
import { brandedId } from 'service/brandedId';
import type { UserEntity } from '../model/userEntity';

Expand Down
2 changes: 1 addition & 1 deletion server/domain/user/useCase/userUseCase.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { UserDto } from 'api/@types/user';
import type { UserDto } from 'common/types/user';
import { prismaClient, transaction } from 'service/prismaClient';
import type { JwtUser } from 'service/types';
import { userMethod } from '../model/userMethod';
Expand Down
2 changes: 1 addition & 1 deletion server/service/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ import fastifyHttpProxy from '@fastify/http-proxy';
import type { TokenOrHeader } from '@fastify/jwt';
import fastifyJwt from '@fastify/jwt';
import fastifyWebsocket from '@fastify/websocket';
import { IS_PROD, WS_PATH } from 'api/@constants';
import assert from 'assert';
import { IS_PROD, WS_PATH } from 'common/constants';
import type { FastifyInstance, FastifyRequest } from 'fastify';
import Fastify from 'fastify';
import buildGetJwks from 'get-jwks';
Expand Down
4 changes: 2 additions & 2 deletions server/service/brandedId.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { BRANDED_ID_NAMES } from 'api/@constants';
import type { DtoId, MaybeId } from 'api/@types/brandedId';
import { BRANDED_ID_NAMES } from 'common/constants';
import type { DtoId, MaybeId } from 'common/types/brandedId';
import { z } from 'zod';

type IdName = (typeof BRANDED_ID_NAMES)[number];
Expand Down
2 changes: 1 addition & 1 deletion server/service/types.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
import type { DtoId } from 'api/@types/brandedId';
import type { DtoId } from 'common/types/brandedId';

export type JwtUser = { sub: DtoId['user']; 'cognito:username': string; email: string };
6 changes: 3 additions & 3 deletions server/service/websocket.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { WS_PING, WS_PONG } from 'api/@constants';
import type { DtoId } from 'api/@types/brandedId';
import type { WebSocketData } from 'api/@types/websocket';
import { WS_PING, WS_PONG } from 'common/constants';
import type { DtoId } from 'common/types/brandedId';
import type { WebSocketData } from 'common/types/websocket';
import type { FastifyInstance } from 'fastify';
import { WebSocket } from 'ws';

Expand Down
2 changes: 1 addition & 1 deletion server/tests/api/apiClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import {
AdminInitiateAuthCommand,
} from '@aws-sdk/client-cognito-identity-provider';
import api from 'api/$api';
import { WS_PATH } from 'api/@constants';
import axios from 'axios';
import { WS_PATH } from 'common/constants';
import { COOKIE_NAME } from 'service/constants';
import {
API_BASE_PATH,
Expand Down
4 changes: 2 additions & 2 deletions server/tests/api/private/di.test.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import type { Prisma } from '@prisma/client';
import type { DtoId } from 'api/@types/brandedId';
import type { UserDto } from 'api/@types/user';
import controller from 'api/private/tasks/di/controller';
import type { DtoId } from 'common/types/brandedId';
import type { UserDto } from 'common/types/user';
import type { TaskEntity } from 'domain/task/model/taskEntity';
import fastify from 'fastify';
import { brandedId } from 'service/brandedId';
Expand Down
4 changes: 2 additions & 2 deletions server/tests/api/private/tasks.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { WS_TYPES } from 'api/@constants';
import type { TaskCreatedEvent, TaskDeletedEvent, TaskUpdatedEvent } from 'api/@types/task';
import { WS_TYPES } from 'common/constants';
import type { TaskCreatedEvent, TaskDeletedEvent, TaskUpdatedEvent } from 'common/types/task';
import { expect, test } from 'vitest';
import { createSessionClients, noCookieClient } from '../apiClient';
import { DELETE, GET, PATCH, POST, WS } from '../utils';
Expand Down
2 changes: 1 addition & 1 deletion server/tests/api/utils.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { WS_TYPES } from 'api/@constants';
import type { WS_TYPES } from 'common/constants';
import { SERVER_PORT } from 'service/envValues';

export const TEST_PORT = SERVER_PORT - 1;
Expand Down
9 changes: 1 addition & 8 deletions server/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,5 @@
"strictPropertyInitialization": false,
"target": "es6",
"incremental": true
},
"include": ["**/*.ts", "**/*.js"],
"exclude": [
"node_modules",
"api/@types/$relay.ts",
"api/@constants/$relay.ts",
"api/@validators/$relay.ts"
]
}
}
3 changes: 1 addition & 2 deletions tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,5 @@
"jsx": "preserve",
"types": ["vitest/importMeta"],
"incremental": true
},
"include": ["**/*.ts", "**/*.tsx"]
}
}

0 comments on commit f81cc39

Please sign in to comment.