This library has a variety of classes and functions to simplify building backend applications with the specific architecture within @sdflc
ecosystem.
This is the class that should be extended when you create a new core class. This is where all the business logic should be happeninng when processing request.
Here are the props to be passed to the BaseCore constructor:
- db: Database - an object of Database class
- context?: any - the request context where you can add all you need, optional
- gateway?: any - main gateway class object that will be working with DB or 3rd part API
- gateways?: any - an object
- isProduction: boolean - true when the app is in production
- logLevel: LoggerLevels - log leves: 0 - none, 1 - errors, 2 - warnings, 3 - messages, 4 - all
- logger?: Logger - object of Logger class to be used as logger
- name?: string - name of the core
- requestId: string - Unique ID of a request processed, can be used for troubleshooting
- doAuth: boolean - call authorize method or not an incoming request
- doingWhat?: BaseCoreDoingWhatInterface - an object with text descriptions of each action, used to generate generic error message sent to user on an exception
- validators?: BaseCoreValidatorsInterface - an object with validator functions to be used to validate incoming data
- 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
- interserviceApiKey?: string - API key to be used to authenticate incoming request from another microservice, optional
- jwtSecret?: string - secret to be used to validate Authorize Bearer token on incoming request, optional
- verifytokenArgs?: VerifyUserTokenArgs - optional parameters for JWT token validation, like algorithm, etc
This is the class that should be extended when you create a new gateway class. This is where your code works with database or 3rd party API or do some works of the lowest level. Gateways are used by the core classes to actually do the job to implement one or another business logic.
This function builds configuration object for a gateways inherited from the BaseGateway classs
Base constroller class is used to create request handlers for RESTful API and provides some methods to simplify the task of working with requests and responses