mukeba-repository
v1.1.2
Published
Provide an abstract repository layer for Mukeba
Readme
Mukeba Repository Package
Is a package/library that is an abstraction layer for Mukeba services. To avoid having to write the same code over and over again we can use this package.
It is a collection of functions that are used to interact with AWS services such as S3 and DynamoDB.
Package Structure
The package is structured as follows in src directory:
- index.tx file :
- Pulls all the environment variables from .env file and exports them as constants.
- Checks if the required environment variables are present and throws an error if they are not.
- definitions.ts file :
- Contains all the types/models, enums and constants used in the package.
- service :
- Exposes functions that are required by the dependent services. We will try by all means possible to only access functions that are exposed in this folder in the services.
- storage :
- Exposes functions that required by the services in service folder.
- dynamo-store :
- This folder contains functions that configure and interact with DynamoDB. this is where we running CRUD operations.
- s3-store :
- This folder contains functions that configure and interact with S3. this is where we uploading, downloading and deleting files.
- ses :
- Configure and Exposes functions that deal with sending emails. These functions are used/called by mail.service.ts in service folder.
- test :
- Contains all the tests for the package. We are using jest to run the tests.
Terraform
Terraform is a tool that is used to provision and manage infrastruc◊ture as code. The terraform terraform folder contains all the terraform files that are used to provision the infrastructure. for now we are using terraform to provision the following resources:
- AWS S3 bucket
- AWS DynamoDB table
To run terraform
From now on we are running the terraform process through github actions. Any changes to the terraform files will trigger the terraform process on you pull request. the Apply of the plan will br triggered on merge.
The destroy process will be triggered manually when needed.
To publish the package
Now we are running the npm publish process through github actions. ⚠️ Please make sure that the package is built and tested before pushing your pr. ⚠️ Also make sure to update the version in package.json file before pushing your pr. ⚠️ Finally provide a comprehensive description of the changes made in the pr.
npm run build
npm run testHowever if you wish to perform a publication on your local you can follow the following process:
- npm run build
- npm pack
- npm login
- npm publish --access public
ERD
classDiagram
imageData <|-- ArticleImage
imageData <|-- MarcheImage
imageData <|-- PropertieImage
Marche <-- MarcheImage
Article --> User
Marche --> User
Propertie --> User
Propertie --> PropertieImage
Article <-- ArticleImage
class Article {
id: string HK
categoryId: string GI
ownerId: string GI
marcheId: string GI
villeName?: string GI
....
}
class ArticleImage {
id: string HK
data: imageData
}
class Marche {
id: string HK
ownerId: string GI
villeName?: string GI
}
class MarcheImage {
id: string HK
data: imageData
}
class User {
user-pk: string PK
user-sk: string SK
email: string GI
}
class Propertie {
id: string PK
marcheId: string GI
ownerId: string GI
villeName?: string GI
}
class PropertieImage {
id: string PK
data: imageData
}