Skip to content

Commit 9bcebef

Browse files
committed
feat: Add JSDocs and adjust README
1 parent 86a7697 commit 9bcebef

3 files changed

Lines changed: 17 additions & 12 deletions

File tree

base/Services/BaseService.ts

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,18 @@
1-
import { ApiRequestContract } from "../../contracts"
2-
3-
export class BaseService<T extends object> {
1+
export class BaseService<T extends Record<string, any>> {
42
/**
53
* Creates a new instance of the given entity
64
*
75
* @param create Properties of the instance to create.
86
* @return The entity instance to be created
97
*/
10-
async setDataCreate(create: any): Promise<T> {
11-
const model = {};
8+
setDataCreate(create: any): T {
9+
const model: Record<string, any> = {}
1210

1311
Object.entries(create).forEach(([key, value]) => {
1412
model[key] = value;
1513
});
1614

17-
return model as T;
15+
return model as T
1816
}
1917

2018
/**
@@ -24,11 +22,12 @@ export class BaseService<T extends object> {
2422
* @param update Properties to apply as update.
2523
* @return The updated entity instance
2624
*/
27-
async setDataUpdate(model: T, update: any): Promise<T> {
25+
setDataUpdate(model: T, update: any): T {
2826
Object.entries(update).forEach(([key, value]) => {
29-
model[key] = value;
30-
});
27+
// @ts-ignore
28+
model[key] = value
29+
})
3130

32-
return model;
31+
return model
3332
}
3433
}

base/Services/GuardBaseService.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,13 @@
11
import { BaseService } from './BaseService'
22

3-
export class GuardBaseService<T> extends BaseService<T> {
3+
interface IGuard {
4+
id?: string | number
5+
status?: string
6+
deletedAt?: string | Date
7+
user?: any
8+
}
9+
10+
export class GuardBaseService<T extends IGuard> extends BaseService<T> {
411
private _guard: T | undefined
512

613
/**

contracts/index.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
11
export { PaginationContract } from './PaginationContract'
2-
export { GuardTypesContract } from './GuardTypesContract'
32
export { ApiResponseContract, PaginatedResponse } from './ApiResponseContract'
43
export { ApiRequestContract, IncludesContract, OrderByContract, WhereContract } from './ApiRequestContract'

0 commit comments

Comments
 (0)