This repository contains a clean starting environment of NodeJS lambda with Typescript
-
Handler Inside this function, the event is transformed by retrieving only the information we need. (path parameters, query parameters, path, method, body) and then the dispatcher function is called.
-
Dispatcher The dispatcher creates an instance of the ChristmasMarketService and the ValidatorService. A new API string variable is created based on the "${path}:${method}" Validate method of the Validator is called. Switch based on the API string is executed on the Endpoints enum which contains all the API combinations.
-
Validator The validator's constructor is private, the instance is created with the getInstance method. The constructor creates an instance of AJV. The validate method checks if the schema is already present inside the ajv instance cache
- If not, it is imported and added to the ajv cache, after that the method is recalled.
- If is present and the event is has schema error, throws an error
-
Application Service Service with the business logic which contains the methods executed by the dispatcher.
-
AWS SDK Wrapper Services Wrapper service of the AWS SDK in order to avoid duplicated code.