-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: add datatable proper implementation and design with filters
- Loading branch information
Showing
67 changed files
with
1,831 additions
and
190 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,4 @@ | ||
{ | ||
"**/*.{ts,tsx,js,jsx}": ["prettier --write"], | ||
"**/*.{md,mdx,yml,json}": ["prettier --write"], | ||
"commit-msg": ["node scripts/js/commitEmoji.js"] | ||
"**/*.{md,mdx,yml,json}": ["prettier --write"] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
27 changes: 0 additions & 27 deletions
27
packages/backend/src/infrastructure/middleware/locals/withPaginableParams.ts
This file was deleted.
Oops, something went wrong.
13 changes: 8 additions & 5 deletions
13
packages/backend/src/infrastructure/repository/AbstractRepository.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,25 @@ | ||
import { type ZodSchema } from "zod"; | ||
import { DatabaseManager } from "@org/backend/config"; | ||
import { type PaginableRepository } from "@org/backend/infrastructure/repository/PaginableRepository"; | ||
import { type MongoPaginationOptions } from "@org/backend/types"; | ||
import { type PaginationOptions } from "@org/shared"; | ||
import { type PaginationResult } from "@org/shared"; | ||
import * as PaginationUtils from "@org/backend/infrastructure/utils/PaginationUtils"; | ||
|
||
export abstract class AbstractRepository<T> implements PaginableRepository<T> { | ||
export abstract class AbstractRepository<T> { | ||
private readonly schema: ZodSchema<T>; | ||
private readonly searchFields: string[]; | ||
|
||
constructor(schema: ZodSchema<T>) { | ||
this.schema = schema; | ||
this.searchFields = this.buildSearch(); | ||
} | ||
|
||
abstract buildSearch(): string[]; | ||
|
||
protected get collection() { | ||
return DatabaseManager.getInstance().collection(this.schema); | ||
} | ||
|
||
async search(options?: MongoPaginationOptions): Promise<PaginationResult<T>> { | ||
return PaginationUtils.paginate(this.collection, options); | ||
async search(options?: PaginationOptions): Promise<PaginationResult<T>> { | ||
return PaginationUtils.paginate(this.collection, this.searchFields, options); | ||
} | ||
} |
6 changes: 3 additions & 3 deletions
6
packages/backend/src/infrastructure/repository/ErrorLogRepository.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
import { type ErrorLog } from "@org/shared"; | ||
import { type PaginableRepository } from "@org/backend/infrastructure/repository/PaginableRepository"; | ||
import type { PaginationOptions, PaginationResult, ErrorLog } from "@org/shared"; | ||
|
||
export interface ErrorLogRepository extends PaginableRepository<ErrorLog> { | ||
export interface ErrorLogRepository { | ||
search: (options: PaginationOptions) => Promise<PaginationResult<ErrorLog>>; | ||
insertOne: (user: Omit<ErrorLog, "_id">) => Promise<ErrorLog>; | ||
} |
6 changes: 0 additions & 6 deletions
6
packages/backend/src/infrastructure/repository/PaginableRepository.ts
This file was deleted.
Oops, something went wrong.
7 changes: 4 additions & 3 deletions
7
packages/backend/src/infrastructure/repository/UserRepository.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,8 @@ | ||
import { type MongoPaginationOptions } from "@org/backend/types"; | ||
import { type User, type PaginationResult } from "@org/shared"; | ||
import { type User, type PaginationResult, type PaginationOptions } from "@org/shared"; | ||
|
||
export interface UserService { | ||
search: (options?: MongoPaginationOptions) => Promise<PaginationResult<User>>; | ||
deleteByUsername(username: string): Promise<void>; | ||
search: (params: Partial<PaginationOptions>) => Promise<PaginationResult<User>>; | ||
findAll: () => Promise<User[]>; | ||
create: (user: User) => Promise<User>; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
29 changes: 16 additions & 13 deletions
29
packages/backend/src/infrastructure/utils/PaginationUtils.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.