Comments (2)
Hello @arunmenon1975
Sorry for the late reply.
Regarding the database, all repositories use the database for storing/querying information.
I would create the database implementation as such:
- Create a storage interface, like
Store(), Query(), FindAll(), FindOne(), Remove()
and etc. - Create a db implementation that uses the storage
- All repositories use the storage implementation above, which is responsible for the db interaction and your code will look something like this
import ICartRepository from '../../entities/interfaces/cartRepository'
import Product from '../../entities/types/Product'
import AddedToCart from '../../entities/types/AddedToCart'
import RemovedFromCart from '../../entities/types/RemovedFromCart'
class ConcreteCartRepository implements ICartRepository {
protected storage: IStorage
async getAll(): Promise<[]Items> {
let data = this.storage.FindAll()
// do repository specific parsing if needed
return data
}
}
export default ConcreteCartRepository
The added value you get from the above solution is you can switch out the storage mechanism without much hassle.
Regarding logging - I always write to stdout/stderr, because I deploy micro-services on k8s, which in turn has something like a fluentd, which ships the logs to a centralized ELK stack.
Writing logs to stdout can be expensive on CPU, especially in Node.js, which only utilizes a single core on its execution thread, which is why I use logging levels, to ensure that minimum logs are written to info, while a lot of logs are written to debug in case I need them.
The implementation of the logs is the same as any other implementation:
- Create logging interface
- Create logging implementation
- Pass ILogger to all relevant components
In general, You should only print info, error and critical log level in production, regardless of where you write them to.
from clean-architecture-example.
Thanks for a very detailed and informative reply.
Sorry i missed the response then - i had moved on to another approach all together for the project. I was evaluating clean architecture as a viable approach at that point in time.
I have bookmarked this response so that i can return to it for any future needs.
from clean-architecture-example.
Related Issues (1)
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from clean-architecture-example.