The TypeScript Architecture
Data Access Layer
Use the repository pattern to abstract the data access layer using an interface which represents a collection of entities.
Use Kysely to implement repositories with relational databases like SQLite and PostgreSQL.
Combine repositories with the builder pattern to chain collection filters and update the internal where statement of the repository instance. Also use the builder pattern to create and forward units of work.
- Use explicit imports instead of globals, e.g. crypto.randomUUID()
- Use node: prefix for built-in module imports
- Prefer unknown over any types