@sdflc/backend-helpers 1.0.26 → 1.0.29
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/README.md +1 -1
- package/build/{baseController.d.ts → BaseController.d.ts} +0 -0
- package/build/{baseController.js → BaseController.js} +0 -0
- package/build/{baseCore.d.ts → BaseCore.d.ts} +13 -19
- package/build/{baseCore.js → BaseCore.js} +114 -156
- package/build/{baseGateway.d.ts → BaseGateway.d.ts} +14 -11
- package/build/{baseGateway.js → BaseGateway.js} +134 -95
- package/build/{dataCache.d.ts → DataCache.d.ts} +0 -0
- package/build/{dataCache.js → DataCache.js} +2 -2
- package/build/{database.d.ts → Database.d.ts} +0 -0
- package/build/{database.js → Database.js} +0 -0
- package/build/{dbMigratorAndSeeder.d.ts → DbMigratorAndSeeder.d.ts} +0 -0
- package/build/{dbMigratorAndSeeder.js → DbMigratorAndSeeder.js} +0 -0
- package/build/apiContext.d.ts +3 -3
- package/build/apiContext.js +89 -32
- package/build/constants.d.ts +4 -5
- package/build/constants.js +18 -4
- package/build/dbTableHelpers.js +29 -33
- package/build/index.d.ts +8 -10
- package/build/index.js +17 -20
- package/build/interfaces/ApiContext.d.ts +23 -0
- package/build/interfaces/{BaseCoreInterface.js → ApiContext.js} +0 -0
- package/build/interfaces/ApiContextInterface.d.ts +5 -1
- package/build/interfaces/BaseCorePropsInterface.d.ts +31 -0
- package/build/interfaces/{BaseGatewayInterface.js → BaseCorePropsInterface.js} +0 -0
- package/build/interfaces/BaseGatewayPropsInterface.d.ts +29 -0
- package/build/interfaces/BaseGatewayPropsInterface.js +2 -0
- package/build/interfaces/CacheInterface.d.ts +3 -3
- package/build/interfaces/CoreActionInterface.d.ts +1 -1
- package/build/interfaces/JwtTokenSecretAndSettings.d.ts +5 -0
- package/build/interfaces/JwtTokenSecretAndSettings.js +2 -0
- package/build/interfaces/index.d.ts +4 -2
- package/build/resolversHelpers.js +11 -10
- package/build/userToken.js +3 -3
- package/package.json +2 -2
- package/build/baseGatewayHelpers.d.ts +0 -20
- package/build/baseGatewayHelpers.js +0 -87
- package/build/interfaces/BaseCoreInterface.d.ts +0 -43
- package/build/interfaces/BaseGatewayInterface.d.ts +0 -27
package/README.md
CHANGED
|
@@ -24,7 +24,7 @@ Here are the props to be passed to the BaseCore constructor:
|
|
|
24
24
|
- doAuth: boolean - call authorize method or not an incoming request
|
|
25
25
|
- doingWhat?: BaseCoreDoingWhatInterface - an object with text descriptions of each action, used to generate generic error message sent to user on an exception
|
|
26
26
|
- validators?: BaseCoreValidatorsInterface - an object with validator functions to be used to validate incoming data
|
|
27
|
-
-
|
|
27
|
+
- spaceGw?: BaseGateway - gateway to find a space, i.e. configration of the app. Each app can have several configurations to be used as one instance for different applications
|
|
28
28
|
- interserviceApiKey?: string - API key to be used to authenticate incoming request from another microservice, optional
|
|
29
29
|
- jwtSecret?: string - secret to be used to validate Authorize Bearer token on incoming request, optional
|
|
30
30
|
- verifytokenArgs?: VerifyUserTokenArgs - optional parameters for JWT token validation, like algorithm, etc
|
|
File without changes
|
|
File without changes
|
|
@@ -1,28 +1,15 @@
|
|
|
1
1
|
import { Logger } from '@sdflc/utils';
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import { Database } from './database';
|
|
2
|
+
import { Database } from './Database';
|
|
3
|
+
import { BaseCorePropsInterface, BaseCoreActionsInterface, CoreActionInterface, BaseCoreValidatorsInterface, JwtTokenSecretAndSettings, ApiContext } from './interfaces';
|
|
5
4
|
declare class BaseCore {
|
|
6
|
-
protected
|
|
7
|
-
protected db: Database;
|
|
8
|
-
protected context: any;
|
|
9
|
-
protected doingWhat?: BaseCoreDoingWhatInterface;
|
|
5
|
+
protected config: BaseCorePropsInterface;
|
|
10
6
|
protected logger: Logger;
|
|
11
|
-
|
|
12
|
-
protected gateway?: any;
|
|
13
|
-
protected gateways?: any;
|
|
14
|
-
protected gwSpace?: any;
|
|
15
|
-
protected interserviceApiKey?: string;
|
|
16
|
-
protected jwtSecret: string;
|
|
17
|
-
protected verifytokenArgs?: VerifyUserTokenArgs;
|
|
18
|
-
protected requestId: string;
|
|
19
|
-
protected validators: BaseCoreValidatorsInterface;
|
|
20
|
-
protected doAuth: boolean;
|
|
21
|
-
constructor(props: BaseCoreInterface);
|
|
7
|
+
constructor(props: BaseCorePropsInterface);
|
|
22
8
|
getDb(): Database;
|
|
23
9
|
getRequestId(): string;
|
|
24
|
-
getContext(
|
|
10
|
+
getContext(): ApiContext;
|
|
25
11
|
getGateways(): any;
|
|
12
|
+
getValidators(): BaseCoreValidatorsInterface;
|
|
26
13
|
success(data: any, code?: number): any;
|
|
27
14
|
failure(code: number, errorMsg: string, data?: any): any;
|
|
28
15
|
validationFailure(ex: any): any;
|
|
@@ -39,6 +26,7 @@ declare class BaseCore {
|
|
|
39
26
|
set(args: any): Promise<any>;
|
|
40
27
|
remove(args: any): Promise<any>;
|
|
41
28
|
removeMany(args: any): Promise<any>;
|
|
29
|
+
defaultAfterAndBefore(params: any, opt?: BaseCoreActionsInterface): Promise<any>;
|
|
42
30
|
beforeList(params: any, opt?: BaseCoreActionsInterface): Promise<any>;
|
|
43
31
|
afterList(params: any, opt?: BaseCoreActionsInterface): Promise<any>;
|
|
44
32
|
beforeCreate(params: any, opt?: BaseCoreActionsInterface): Promise<any>;
|
|
@@ -56,6 +44,12 @@ declare class BaseCore {
|
|
|
56
44
|
beforeRemoveMany(params: any, opt?: BaseCoreActionsInterface): Promise<any>;
|
|
57
45
|
afterRemoveMany(params: any, opt?: BaseCoreActionsInterface): Promise<any>;
|
|
58
46
|
onException(params: any, opt?: BaseCoreActionsInterface): Promise<any>;
|
|
47
|
+
/**
|
|
48
|
+
* Returns JWT secret and its settings to verify received JWT token
|
|
49
|
+
* @param params Object of parameters passed to the authenticate method
|
|
50
|
+
* @returns Object with the jwtSecret and verifyTokenArgs
|
|
51
|
+
*/
|
|
52
|
+
getJwtTokenSecretAndSettings(params: any): Promise<JwtTokenSecretAndSettings>;
|
|
59
53
|
authenticate(params: any, opt?: BaseCoreActionsInterface): Promise<any[]>;
|
|
60
54
|
}
|
|
61
55
|
export { BaseCore };
|