Skip to content

Commit

Permalink
Refactor example code: use import type for types import
Browse files Browse the repository at this point in the history
  • Loading branch information
suhaotian committed Dec 2, 2023
1 parent 6f4726f commit a9d5fa8
Show file tree
Hide file tree
Showing 12 changed files with 18 additions and 35 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@ export enum TodoStatus {
deleted = 'deleted',
}

export const todoStatus = Object.values(TodoStatus);

const entityName = 'todo_item';

export class Todo extends CreatedUpdatedAt {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { z } from 'zod';
import { Todo } from '../Todo.entity';
import type { Todo } from '../Todo.entity';
import { addTodoSchema } from './TodoSchema.shared';
import { InsertResult, transformPath, APIConfig, ObjectLiteral } from '../../../shared/tsdk-helper';
import { InsertResult, transformPath, APIConfig } from '../../../shared/tsdk-helper';

export const AddTodoConfig: APIConfig = {
type: 'user',
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,7 @@
import { transformPath } from '../../../shared/tsdk-helper';
import { Todo } from '../Todo.entity';
import type { Todo } from '../Todo.entity';
import { deleteTodoSchema } from './TodoSchema.shared';
import {
APIConfig,
DeleteResult,
ObjectLiteral,
RequireOnlyOne,
} from '../../../shared/tsdk-helper';
import { APIConfig, DeleteResult, RequireOnlyOne } from '../../../shared/tsdk-helper';

export const DeleteTodoConfig: APIConfig = {
type: 'user',
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Todo } from '../Todo.entity';
import type { Todo } from '../Todo.entity';
import { queryTodoSchema } from './TodoSchema.shared';
import { Paging, PagingRes } from '../../../shared/paging';
import { APIConfig, transformPath, ObjectLiteral } from '../../../shared/tsdk-helper';
import { APIConfig, transformPath } from '../../../shared/tsdk-helper';

export const QueryTodoConfig: APIConfig = {
path: transformPath('QueryTodo'),
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
import { z } from 'zod';
import { Todo } from '../Todo.entity';
import type { Todo } from '../Todo.entity';
import { queryTodoByCursorSchema } from './TodoSchema.shared';
import { Paging, PagingRes } from '../../../shared/paging';
import { APIConfig, ObjectLiteral, transformPath } from '../../../shared/tsdk-helper';
import { APIConfig, transformPath } from '../../../shared/tsdk-helper';

/**
* query todo list by cursor ({@link APIConfig})
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
import { Todo } from '../Todo.entity';
import type { Todo } from '../Todo.entity';
import { updateTodoSchema } from './TodoSchema.shared';
import {
APIConfig,
ObjectLiteral,
RequireAtLeastOne,
transformPath,
UpdateResult,
Expand Down
2 changes: 0 additions & 2 deletions examples/server/src/modules/todo/Todo.entity.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@ export enum TodoStatus {
deleted = 'deleted',
}

export const todoStatus = Object.values(TodoStatus);

const entityName = 'todo_item';

@Entity({ name: entityName })
Expand Down
6 changes: 2 additions & 4 deletions examples/server/src/modules/todo/apiconf/AddTodo.apiconf.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
import { z } from 'zod';

import { Todo } from '../Todo.entity';
import type { Todo } from '../Todo.entity';
import { addTodoSchema } from './TodoSchema.shared';

import { InsertResult, transformPath, APIConfig, ObjectLiteral } from '@/src/shared/tsdk-helper';
import { InsertResult, transformPath, APIConfig } from '@/src/shared/tsdk-helper';

export const AddTodoConfig: APIConfig = {
type: 'user',
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { transformPath } from '/src/shared/tsdk-helper';

import { Todo } from '../Todo.entity';
import type { Todo } from '../Todo.entity';
import { deleteTodoSchema } from './TodoSchema.shared';

import { APIConfig, DeleteResult, ObjectLiteral, RequireOnlyOne } from '@/src/shared/tsdk-helper';
import { APIConfig, DeleteResult, RequireOnlyOne } from '@/src/shared/tsdk-helper';

export const DeleteTodoConfig: APIConfig = {
type: 'user',
Expand Down
4 changes: 2 additions & 2 deletions examples/server/src/modules/todo/apiconf/QueryTodo.apiconf.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { Todo } from '../Todo.entity';
import type { Todo } from '../Todo.entity';
import { queryTodoSchema } from './TodoSchema.shared';

import { Paging, PagingRes } from '@/src/shared/paging';
import { APIConfig, transformPath, ObjectLiteral } from '@/src/shared/tsdk-helper';
import { APIConfig, transformPath } from '@/src/shared/tsdk-helper';

export const QueryTodoConfig: APIConfig = {
path: transformPath('QueryTodo'),
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
import { z } from 'zod';

import { Todo } from '../Todo.entity';
import type { Todo } from '../Todo.entity';
import { queryTodoByCursorSchema } from './TodoSchema.shared';

import { Paging, PagingRes } from '@/src/shared/paging';
import { APIConfig, ObjectLiteral, transformPath } from '@/src/shared/tsdk-helper';
import { APIConfig, transformPath } from '@/src/shared/tsdk-helper';

/**
* query todo list by cursor ({@link APIConfig})
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
import { Todo } from '../Todo.entity';
import type { Todo } from '../Todo.entity';
import { updateTodoSchema } from './TodoSchema.shared';

import {
APIConfig,
ObjectLiteral,
RequireAtLeastOne,
transformPath,
UpdateResult,
Expand Down

0 comments on commit a9d5fa8

Please sign in to comment.