@ccci/micro-server 1.0.126 → 1.0.127
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +1 -1
- package/dist/index.js +704 -668
- package/dist/types/BaseControllerTypes.d.ts +3 -0
- package/dist/utils/BaseController.d.ts +10 -0
- package/dist/utils/BaseControllerHelper.d.ts +20 -0
- package/dist/utils/BaseRouter.d.ts +7 -0
- package/dist/utils/{WebSocketServer.d.ts → WebsocketServer.d.ts} +1 -1
- package/package.json +1 -1
|
@@ -5,11 +5,13 @@ export type RequestQuery = {
|
|
|
5
5
|
page?: number;
|
|
6
6
|
includes?: string;
|
|
7
7
|
fields?: string;
|
|
8
|
+
paranoid?: string;
|
|
8
9
|
sort?: string;
|
|
9
10
|
paginate?: string;
|
|
10
11
|
date_range?: string;
|
|
11
12
|
others?: any;
|
|
12
13
|
scan?: string;
|
|
14
|
+
groupBy?: string;
|
|
13
15
|
};
|
|
14
16
|
export type QueryOptions = {
|
|
15
17
|
where?: WhereOptions<any>;
|
|
@@ -17,6 +19,7 @@ export type QueryOptions = {
|
|
|
17
19
|
offset?: number;
|
|
18
20
|
attributes?: Array<string>;
|
|
19
21
|
order?: Order;
|
|
22
|
+
paranoid?: boolean;
|
|
20
23
|
includes?: Array<string | IncludeType>;
|
|
21
24
|
};
|
|
22
25
|
export type ResponseType = {
|
|
@@ -69,6 +69,16 @@ export default class BaseController {
|
|
|
69
69
|
count(req: Request, res: Response, next?: NextFunction): Promise<{
|
|
70
70
|
count: number;
|
|
71
71
|
}>;
|
|
72
|
+
/**
|
|
73
|
+
* Return a basic statistics based on the query and group provided.
|
|
74
|
+
* ```js
|
|
75
|
+
* Controller.find(req, res, next)
|
|
76
|
+
* ```
|
|
77
|
+
* @param req
|
|
78
|
+
* @param res
|
|
79
|
+
* @param next
|
|
80
|
+
*/
|
|
81
|
+
stats(req: Request, res: Response, next?: NextFunction): Promise<any>;
|
|
72
82
|
/**
|
|
73
83
|
* ###############################################################
|
|
74
84
|
* ###################### LIFE CYCLE HOOKS #######################
|
|
@@ -1,7 +1,27 @@
|
|
|
1
1
|
import { BaseError, UniqueConstraintError } from "sequelize";
|
|
2
2
|
import { RequestQuery, QueryOptions, ResponseType } from "../types/BaseControllerTypes";
|
|
3
|
+
/**
|
|
4
|
+
* Constructs a Sequelize query object based on the provided request query.
|
|
5
|
+
* This function dynamically builds the `where` clause, allows for sorting,
|
|
6
|
+
* pagination, field selection, and includes related models.
|
|
7
|
+
*
|
|
8
|
+
* @param {RequestQuery} query - The incoming request query parameters.
|
|
9
|
+
* @returns {QueryOptions} - Returns a Sequelize query options object to be used for querying the database.
|
|
10
|
+
*/
|
|
3
11
|
export declare function ConstructQuery(query: RequestQuery): QueryOptions;
|
|
12
|
+
/**
|
|
13
|
+
* A helper function to structure a successful response.
|
|
14
|
+
*
|
|
15
|
+
* @param {any} response - Data to include in the response.
|
|
16
|
+
* @returns {ResponseType} - An object with success status and response data.
|
|
17
|
+
*/
|
|
4
18
|
export declare function ResponseHelper(response?: any): ResponseType;
|
|
19
|
+
/**
|
|
20
|
+
* Handles errors and constructs an error response based on the type of error (Sequelize, database, or validation).
|
|
21
|
+
*
|
|
22
|
+
* @param {UniqueConstraintError | BaseError | Error | any} error - The error encountered during execution.
|
|
23
|
+
* @returns {ResponseType} - Returns a structured error response with error codes and messages.
|
|
24
|
+
*/
|
|
5
25
|
export declare function ErrorResponseHandler(error: UniqueConstraintError | BaseError | Error | any): ResponseType;
|
|
6
26
|
export { ResponseType };
|
|
7
27
|
//# sourceMappingURL=BaseControllerHelper.d.ts.map
|
|
@@ -65,6 +65,13 @@ export default class BaseRouter<T extends BaseController> {
|
|
|
65
65
|
* @param next
|
|
66
66
|
*/
|
|
67
67
|
count(req: Request, res: Response, next: NextFunction): Promise<void>;
|
|
68
|
+
/**
|
|
69
|
+
* /stats get count by group
|
|
70
|
+
* @param req
|
|
71
|
+
* @param res
|
|
72
|
+
* @param next
|
|
73
|
+
*/
|
|
74
|
+
stats(req: Request, res: Response, next: NextFunction): Promise<void>;
|
|
68
75
|
/**
|
|
69
76
|
* @description default mappings that will be inherited across all router class
|
|
70
77
|
* @returns {Array} mappings
|